Monday 23 January 2012

Variables on Flash

1) Open Flash in Actionscript2.

2) Name your first layer AS (for action script). Then make a new layer and name it button.

3) In the layer named button, make a circle. Right click on the circle --> convert symbol --> movie clip. Also rename it button.

4) Make sure you have the AS layer selected on the Timetable. Then click F9 to get up the Actions option. Here you can do all your coding. The first piece of coding will be...
var stands for variable and creates a new variable.
If you see a //at the beginning of a line in the coding it is commenting it out. Meaning it will ignore that line of the coding.

5) Click on the button and name it in the top right hand corner under Properties where it says Instance name. Click back on the Timeline on the AS layer to carry on coding.
6) This piece of coding means that everytime the button is clicked it will move 5 pixels to the right. I will comment this out but it is just a good example of what ou can do. The coding also means that everytime the button is clicked the output number will go up by 1.
7) Now after the button is clicked 9 times the output goes from saying numbers to saying 'true'.

8) Now when the button is un-clicked or clicked less then 9 times the Output reads 'false'.


9) You next enter a text box onto the AS layer. In the Properties section make sure the text box is a Dynamic Text. You then go into the Options and in the Variable section write score.
Now when you you Ctrl Enter to preview the button working the text box shows the score number.

No comments:

Post a Comment