Quick actionscript 2.0 question.

6 posts

Flag Post

Hi, I am creating a game with Flash MX 2004. I have created a movieclip and once it reaches a certain frame I want to add 1 to a text box on the stage. I have looked on the internet for a while now and I can’t find any advice. Could someone give me code for actionscript 2.0 that allows me to do this? Thanks.

 
Flag Post

Couple ways, actually.

First, the text box needs to be dynamic and have an identifier (there are two properties that you can mess with, use the one that doesn’t say “variable”). I’m going to call it myText
Second, create a keyframe on the timeline of the movieclip. In this keyframe hit F9 to bring up the actions panel. Type:

_root.myText.text = parseInt(_root.myText.text) + 1;
 
Flag Post
Originally posted by Draco18s:

Couple ways, actually.

First, the text box needs to be dynamic and have an identifier (there are two properties that you can mess with, use the one that doesn’t say “variable”). I’m going to call it myText
Second, create a keyframe on the timeline of the movieclip. In this keyframe hit F9 to bring up the actions panel. Type:

_root.myText.text = parseInt(_root.myText.text) + 1;

Thanks, I will try this tomorrow when I have access to flash. By the way, do this allow me to use this as a numerical value as opposed to just text? I plan on making a scoring system based on this code.

 
Flag Post

_root.myText.text is a string, but parseInt() converts a string to a numerical value. Then the code adds 1 and converts it back to a string.

However, it’s better to store the score as an int, rather than converting it back and forth every time.

 
Flag Post

The answer is AS3

 
Flag Post
Originally posted by Darkscanner:

The answer is AS3

Says a guy who programs in AS2.