Thursday, December 24, 2009

How do I create a variable in Flash Actionscript?

I’m looking to create a game show interactive game in flash, but I don’t know how to make a graphic keep score. Unfortunately all I know is how to do in Flash is make frames loop and basic “send to” buttons. I just don’t know much code; does any one know what code I could?How do I create a variable in Flash Actionscript?
What you may need to use is a Dynamic Text Box. Select the Text Tool and then drag out a box and then open the Properties Panel and change Static Text to Dynamic Text. Then you need to change the ';Var'; to what ever you want. Name it something that applies to the function of the text box but make sure that there are no spaces. Let's call it ';score';





Now deselect everything and open up the Actions panel and type:


_root.score = 0;


You can change the number to what ever you want.





Now, to make the score increase you use:


_root.clicks += 1;


You can change the + to - to make it decrease and you can also change the amount that it changes by. You will need to put this in between an event such as a mouseclick or a hitTest, it's really up to you.

No comments:

Post a Comment