<< Chapter < Page | Chapter >> Page > |
A stand alone Flash Player
It is also worth noting that in all five cases, the standalone Flash Player was running, as opposed to the Flash Player plug-in for a browser.Therefore, these results were not influenced by the behavior of any specific browser.
In the remainder of this lesson, I will explain three different animation projects.
Run the ActionScript projects
If you have the Flash Player plug-in (version 9 or later) installed in your browser, you can click here to run the projects that I will explain in this lesson.
If you don't have the proper Flash Player installed, you should be notified of that fact and given an opportunity to download and install the Flash Playerplug-in program.
I will explain the remaining projects in this lesson in fragments. A complete listing of the code for the project named Animation01 is provided in Listing 18 near the end of the lesson.
This is a very simple AS3 animation project. (Note that it is not a Flex project.)
I recommend that you run the online version of this project before continuing. (See Deployment of FlashDevelop projects for information on how to deploy a release build from a FlashDevelop project on the Connexions website.)
The ENTER_FRAME event stream
This project uses the ENTER_FRAME event stream as a time base to cause a filled blue circle drawn on a transparent Sprite object to move diagonally from left to right across the Flash window. The spritewith the circle moves out of the Flash window at the bottom right.
Beginning of the class named Main
This project was developed using the FlashDevelop tool. By default, the FlashDevelop tool names the required source code file andclass definition Main . Listing 1 shows the beginning of the Main class for the project named Animation01 .
package {
import flash.display.Sprite;import flash.events.Event;public class Main extends Sprite{
private var sprite:Sprite;private var dx:Number = 3;//x-movement distance
private var dy:Number = 2;//y-movement distanceprivate var radius:Number = 24;//radius of circle
Not much that is new here
The class named Main extends the class named Sprite , which is a subclass of the class named DisplayObject several levels down the inheritance hierarchy. Therefore, the Flash Player will instantiate an object of this class and addit to the display list.
Otherwise, there is nothing in Listing 1 that should be new to you, so no further explanation of the code in Listing 1 should be required.
Beginning of the constructor
The beginning of the constructor for the Main class is shown in Listing 2.
public function Main():void {
sprite = new Sprite();//Enable the following statement to cause the
// sprite background to be visible.//sprite.opaqueBackground = true;
//Draw a filled circle on the Sprite object;sprite.graphics.beginFill(0x0000ff, 1.0);
sprite.graphics.drawCircle(radius,radius,radius);sprite.graphics.endFill();addChild(sprite);//default location is 0,0
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with actionscript' conversation and receive update notifications?