Game Development Reference
In-Depth Information
and uses than simply stopping a MovieClip from playing. In fact,
I have come up with a way to use this method to overcome a
defect in ActionScript with regards to MovieClips and frame labels.
Since early versions of Flash, you could put string labels on any
frame in the timeline and use them as reference points for naviga-
tion. Starting from AS3, Adobe finally introduced the ability to see
what label you
re currently on in a clip (with the currentLabel prop-
erty), as well as a list of all the labels in a clip (the currentLabels
property). I
ve long thought that Flash should dispatch an event
whenever a frame label is hit, so you could trigger actions based on
label markers. With addFrameScript ,youcan!Let
s look at an
Here is an architecture I like to use for my document class in a
Flash file. It involves placing labels on the main timeline to denote
sections of a game; they might be things such as
and so on. Figure 4.4 illustrates
this arrangement.
In my document class, I create constants to match these frame
labels, so I can reference them easily and don
t risk misspelling them.
I also import the FrameLabel class, as I will be using it shortly.
package {
import flash.display.MovieClip;
import flash.display.FrameLabel;
public class FrameScriptExample extends MovieClip {
static public const FRAME_LOADER:String = " loader " ;
static public const FRAME_TITLE:String = " title " ;
static public const FRAME_GAME:String = " game " ;
static public const FRAME_RESULTS:String = " results " ;
public function FrameScriptExample() {
Once I have all my labels established, I create two functions that
will control my frame events.
private function enumerateFrameLabels():void {
for each (var label:FrameLabel in currentLabels)
addFrameScript(label.frame-1, dispatchFrameEvent);
Figure 4.4 For my main
timeline, I set up labels
denoting each section of the
game experience.
Search Nedrilad ::

Custom Search