<< 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.

This may be entirely wrong from a detailed technical viewpoint, but I will present it for your considerationbecause it seems to describe what actually happens.

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.

Note that some objects, such as Button objects, inherently know how to modify their own attributes under certain circumstances, such as beingrolled over or clicked by the mouse.

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.

Time base considerations

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:

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Object-oriented programming (oop) with actionscript. OpenStax CNX. Jun 04, 2010 Download for free at http://cnx.org/content/col11202/1.19
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with actionscript' conversation and receive update notifications?

Ask