Search tutorials
Requirements:
Flash MX 2004
Things you need to know:
-Variables
-the "random()" function.
if you don't know enough on variables, you should search for a tutorial about it first, which should be relatively easy to find and understand, and then come back here.
if you don't what the "random()" function is, don't fret, it's simple.
basically it returns an absolute number value which is equal to the number inserted in the function or less from numbers 0-x where x is the number inserted in the function.
e.g.: "random(7)" would give a random number from 0 to 7 excluding decimals, being one of the numbers in the parentheses(0,1,2,3,4,5,6,7).
now let's begin.
first, with the property inspector open(Ctrl+F3), select the Text Tool(T) and choose "Dynamic Text" from the property inspector.
now, with the text tool, make an empty text at wanted size as long as it's big enough to display around 5 characters.
now with the Select Tool (V), select the text box you just created.
with the text box selected and the property inspector opened, enter "randomnumber_txt" in the "instance name" area, and enter "randomnumber" in the area with the word "Var:" written to it's left.
now close the property inspector(Ctrl+F3), open the actions panel(F9), and select the first frame of your movie in the timeline. In the Actions box, insert the following code:
//this declares the variables and the "engine" variables random function.
var engine = random(99);
var randomnumber;
//This tells us that you have a 15% chance of getting the number 18
if (engine>=0 && engine<=14) {
randomnumber = 18;
} else if (engine>=15 && engine<=69) {
//This tells us we have a 55% chance of having the number 12
randomnumber = 12;
} else {
//this is the remainding percentage which is accorded to "9".
randomnumber = 9;
}
now you can test it(Ctrl+Enter).
if all is rolling smoothly, you're done. if not, try checking the code or check if you have the right version of flash.
| » Level Basic |
|
Added: 2005-05-01 Rating: 5 Votes: 11 |
| » Author |
| Good engine i built since i couldn't find a tutorial for it. |
| » Download |
| Download the files used in this tutorial. |
| Download (0 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!