Search tutorials
Variables
What YOU need to know
Part 1
If you are serious about making games in flash you NEED to know about variables. Variables have been use in almost every great game there has ever been! There used for things like money , lives , objects and LOADS more things to. So hopefully by the time youve read this tutorial you will know the basics of variables !
------------------------
So in the first tutorial (this one) were going to make a money system !
(note: im working in flash mx 2004 pro , although this should work also with flash 5 , mx , mx 2004)
Ok , so open up flash if you havent all ready. Make a new normal flash file. In the first key frame add this actionscript ;
Money = 1000
This tells flash to set the Variable money which you just created to 1000. a Variable can be called anything and can hold letters and numbers . In this case its holing numbers.
Now make a second layer and call it text . Then rename the other layer to shop.
Click on frame 1 of layer text and make a dynamic textbox. On the text boxes properties were it says var: in the text box to the right type in money.
This tells flash to show what ever the Variable money is holding in that text box. If you test the movie now the text box should say 1000.
Now make a button on the layer shop .
Give the button this actionscript:
on (release) {
money -= 10;
}
Now test the movie again. When you press the button your money gos down 10 each time.
You can also use thisaction script on the button;
on (release) {
money += 10;
}
This adds 10 to your money !
So how could you this what you have just learnt?
Here just two ways;
1) make a shop
2) when you work at a shop you get paid
i hop this was helpful and clear.
ANY problems just email me at ed@edmarriner.co.uk
Thanks
ed
| » Level Intermediate |
|
Added: 2005-01-03 Rating: 7 Votes: 43 |
| » Author |
| im 12 , live in england :) |
| » Download |
| Download the files used in this tutorial. |
| Download (7 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
Mr.
Posted by Brian on 08/13/2012 10:53amHey, man, this was pretty good, taught me a lot. I'm curious, though, how do you keep the "money" counter from going below zero?
Reply