|
|
In response to someone on Flashpad asking how to make a simple, constantly-running counter. Here's the .fla file in zip form.
Quite simple, actually. In this case there are four digits (you could have many more) so numbers up to 9,999 are possible. Each is a separate movie, with the Instance names Digit1, Digit2, Digit3, Digit4 (just to confuse you, Digit1 is on the right, Digit2 the next left and so on -- it'll become clear why in a moment).
All four movies are essentially the same -- ten frames, each containing a number between 0 and 9 (in order, of course). Apart from Digit1, all the movies have Stop actions in the first frame. They also all have an eleventh frame, and this is where the action is.
What happens is this...
All the movies start at frame 1 (ie. all reading 0). Digit1 begins counting (the others are all stopped). When Digit1 gets to frame 11, there's a Tell Target action:
Begin Tell Target [/Digit2]
Go to Next Frame
End Tell Target
Go to and Play [frame 1]
So it instructs Digit2 (which you can think of as the 'tens' digit, where Digit1 is the 'ones' digit) to advance one frame -- ie. to count up by one. It also tells itself (Digit1) to go back to frame 1 - ie. to jump back to 0. So what you get is '10'.
Digit1 now continues counting up from 0 to 9 (ie. from 10 to 19) and when it gets to the eleventh frame again it tells Digit2 to count up another 1 (to 2) and jumps back to zero -- the result is '20'.
Digit2 works in a similar way, but of course when it gets to its eleventh frame, it uses Tell Target to instruct Digit3 (the 'hundreds' column) to count up by one. The result - 100. You can probably guess that Digit3 does the same to Digit4, which represents the 'thousands' column.
When Digit4 gets to its eleventh frame (ie. the counter has reached 9,999) it uses Tell Target to reset all the digits to 0...and the whole thing starts again.
If you don't understand my explanation then you're probably best off just looking through the .fla file -- it's really very simple indeed.
Good luck!
All files and text copyright ©Stickman 1998 - 2003. For copyright and terms of use information, please read this page.