<< Chapter < Page | Chapter >> Page > |
Here is what I believe happens when the html file is opened in a browser that has the Flash Player plug-in installed.
The swf file is opened in the Flash Player
The code inside the html file causes the swf file to be opened in the Flash Player plug-in that has been installed in that browser.
The swf file contains the compiled class definition for the class defined in the source code file mentioned earlier plus a number of other things, including the name of that class. (You can probably think of a swf file as being similar to a zip file or a Java JAR file; a file thatencapsulates other files.)
An object of the class is instantiated
The Flash Player plug-in extracts the name of the class and calls the constructor for that class to instantiate an object of that class.
The constructor is executed
All of the code contained in the constructor plus all of the code called by code in the constructor, plus all of the code called by that code, etc., isexecuted.
Objects of type DisplayObject are displayed
If any of that code instantiates objects that derive from the DisplayObject class and adds those objects to the display list , those objects will be displayed during the next frame.
The current contents of the display list are displayed during each frame
If all of that code terminates without doing something to cause the contents of the display list to be modified or to cause the attributes of those displayobjects to be modified in the future, they will continue to be displayed once during each frame. In that case, the display will appear to be static insofar asthe user is concerned.
Additional code may be executed in the future
The code that is executed and caused to be executed by the constructor may do something to ensure the future execution of additional code, (such as registering TIMER or ENTER_FRAME event listeners).
Code that is executed in the future may modify the display list, may modify the attributes of existing objects on the display list, may instantiate newdisplay objects and add them to the display list, etc. Such changes will be reflected in the visual screen display when they occur.
Frame-to-frame changes in the display
As a result of code that is executed in the future, the display list may change on a frame-to-frame basis causing the physical display to also change ona frame-to-frame basis. In that case, the display won't appear to be static insofar as the user is concerned.
That will be the case for the animation projects that I explain in this lesson.
In many cases when writing animation code, it is appropriate to use a stable time base to control progress through the program. There are at least twodifferent ways to access a time base when writing ActionScript code:
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with actionscript' conversation and receive update notifications?