there are 4 dynamic texts with numbers… and i wanted to know how to do a subtract on one of the 4 dynamic texts randomly…
me not understand. Can U explain in detail (how about an example?)
MONTOYA YOUR BACK!!!
2 posts in two nights (that I saw), is it true, are you back!?!?!
:love:
I think I MIGHT understand, lemme try and whip something up.
OK
First thing First.
Create <B>5</B> textboxes on the stage. Give each an <B>INSTANCE</B> name of textBox#, like this…
textBox1
textBox2
textBox3
textBox4
textBox5
Now on a frame add these actions…
_root.textBox1.text = 10;
_root.textBox2.text = 20;
_root.textBox3.text = 30;
_root.textBox4.text = 40;
ranNum1 = Math.round(Math.random()*(4-1)+1);
ranNum2 = Math.round(Math.random()*(4-1)+1);
box1 = _root["textBox"+ranNum1].text;
box2 = _root["textBox"+ranNum2].text;
_root.textBox5.text = box1+"-"+box2+" = "+(box1-box2);
This assings numbers to each of those textboxes. 10, 20, 30, and 40 as you see.
ranNum1 chooses a number from 1 to 4 to find out which textBox to choose for the first box.
ranNum2 chooses a number from 1 to 4 to find out which textBox to choose for the second box.
box1 takes the number supplied by ranNum1 and tacks it onto the word “textBox” creating one of the instance names of your textbox. It basically turns it into _root.textBox#.text. Where # is the number ranNum1 produces.
box2 does the same but using ranNum2.
the last line here shows the number taken from box1 and box 2, then the results of subtracting them.
Check my example file to see it in action.
im saying like… there is for text numbers
exsample:
four numbers that are in dynamic text:
150
200
250
175
and when it subtracts it randomly picks one of those…
i already did the random subracting numbers like “Math.floor(Math.random() * (20 - 10)) + 10;”…
That is what my code does. Except I assigned the number to the textbox through AS.