I'm working on a Flash game where there are scenes that display a few stages of animation; the animation is controlled by user-clickable buttons (1 through 4) and a progress bar which increases by some amount with a timer.
Right now I have each stage of the animation on a different frame, but I'm not sure how to share the Actionscript and state (e.g. value of the progress var) across the frames.
Should I consolidate these frames into one and let each piece (the buttons, progress bar, and animation) all be three separate movie clips that are controlled by the actionscript of that frame? Or is there another way to do this properly?
What you said is probably the best solution in this case: put everything on one frame and control with ActionScript. The buttons can be their own MovieClip
s (or Button
s), the progress bar and animation as well. You can then have each stage of the animation on a different frame within the MovieClip
, and control which frame appears when using gotoAndStop()
.
Generally I only use the base frames (i.e. those at the root of an SWF) as animation frames if the SWF is purely animation with no or minimal ActionScript involved. In any other case (games, applications, etc) it's always better to have animations in their own MovieClip
s, so that you can control and manipulate them easily.