Here's how the preceding code works. At the top you will see the import commands for all of the classes used within the document. Below that is the class declaration. This class is an extension of the Movieclip class because it is attached to my main FLA file, which can only instantiate a Movieclip.
Inside the Class declaration is the main constructor. This is the big branch that will spawn all of the little branches. Now within the constructor there is only one function to b run. This is PlusListeners(). All this function does is add ten event listeners to the stage.
As you can see in the body of PlusListeners(), each of the ten listeners is identical. Each listener waits for the FLA stage to dispatch an event. The name of that event is ENTER_FRAME. This event is dispatched every time the animation moves forward a frame, which will occur automatically unless you tell Flash to stop moving forward.
Anyway, at the end of each listener a function is called. In the first listener, that function is called Event1. After the right brace signifies that PlusListeners() is complete, each of the "Event" functions is . In the case of Event1, all the function does is call a trace function.
private function Event1(event:Event):void {
trace("This is event1")
}
This message will be printed in the output window of Flash every time a frame is passed in the animation.
You'll notice that at the end of the Actionscript file are three braces. The first declares an end to the Event10 function, the second declares that the Structure class has been completed, and the third denotes the completion of the package.
No comments:
Post a Comment