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

The two projects discussed above were developed using the FlashDevelop tool. By default, the Test Movie option on the FlashDevelop Project Menu runsthe project in a stand alone Flash Player and not in a browser plug in.

Preview

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.

Discussion and sample code

The project named Animation01

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 .

Beginning of the class named main.

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.

Beginning of the constructor.

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

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