How do I change variables?

Hey all

I’ve got a falling ball with many variables (“gravity”; “bounce”; “drag”; etc). How can I create a way to have my viewers change the variable amounts by physically typing in a number when they view the movie? I’ve got a “++” and “–” button, but those only seem to change the ball’s variable while in motion. And as it takes about one second for the ball to fall, that’s kind of pointless. Basically, I want an effective way for my viewers to play with the variables of a falling ball. And speak slowly, I am very much a novice at AS.

[email protected]

And this is for FlashMX

Okay, I don’t have flash in front of me, so bear with me. You can create an input textbox on the stage with the text tool. Give it an instance name, like “speedtext”

Okay, now, script this in the actionscript window for the textbox “speedtext”:

[AS]_global.speedvar = this.text;[/AS]

Now, put a button next to the textbox, give it an instance name “speedbutton” and code it as follows:


then, on the ball movie clip, give it an instance name of “ball”, and put a stop() action in the first frame of the movie. Then, put all your ball manipulation code in the second frame, and make sure that when you declare your variable “gravity” it is outside of the onClipEvent(enterFrame) tag. It should work then, I think. Post your .fla or code if you want a more complete answer.


It doesnt seem to be working…

Within my ball movieclip I already have “gravity=5” among other things… Do I have to set this “5” to “speedvar” or something else?


yeah, try setting gravity to speedvar, but I would really like to see your .fla
Post it here if you can.


The .fla is too big. Can I email it to you?

[email protected]

its probably because youre taking in the text box as text…do som,ething like Num(this.text)