<< Chapter < Page Chapter >> Page >

This causes the material shown in Figure 2 to be displayed in the system console window each time the Flash Player gains and then loses the operatingsystem focus.

Listing 3 also signals the end of the class and the end of the program named ActivateEvent01 .

The program named Effects03

This is a much more substantial program, which is based on a program in the Flex documentation . That program is written mostly in Flex MXML and contains the minimum amount of ActionScript code necessary to provide thedesired behavior.

Online versions of the two programs

An online executable version of the program is available following the source code listing at the above site . I encourage you to run it and observe its behavior.

This version of the program is written almost entirely in ActionScript and contains only enough Flex MXML to make it possible to launchthe program from within an HTML document. I also encourage you to run this version and observe its behavior.

Project file structure for Effects03

The project file structure for the program is shown in Figure 3, which shows a snapshot of the Flex Builder 3 Navigator panel.

Project file structure for effects03.

Missing image
Project file structure for Effects03.

Screen display at startup

The screen display at startup is shown in Figure 4.

Screen display at startup.

Missing image
Screen display at startup.

A creationComplete event

By the time that the snapshot shown in Figure 4 was taken, the application had already dispatched a creationComplete event and the event handler registered to listen for that event had caused the text "Creation Complete!" tobe displayed in a TextArea object near the top of the browser window.

What is a creationComplete event?

According to the documentation , this event is dispatched "when the component has finished its construction, property processing, measuring, layout, and drawing." Therefore, other than the fact that the user starts the program running, thedispatching of this event type is completely beyond the control of the user.

Behavior of the program

This program uses a Resize object from the mx.effects package to cause the size of the image of the penguin shown in Figure 4 to be reduced to one-fourth of its original size over a period of 10seconds when the user clicks the Start button shown at the bottom of Figure 4.

The behavior of the effect resulting from clicks on the other buttons at the bottom of Figure 4 generally matches the labels on the buttons.

Screen display after clicking Start and Pause

Figure 5 shows the screen display after clicking the Start button, allowing the effect to run for a few seconds, and then clicking the Pause button.

Screen display after clicking start and pause.

Missing image
Screen display after clicking Start and Pause.

Servicing an effectStart event

As you will see later, clicking the Start button causes a method named play to be called on an object of the Resize class.

The Resize object dispatches an effectStart event whenever it starts playing an effect. An event handler, registered on the Resize object, causes the text "Effect Started!" to be displayed in the text area near the top of Figure 5.

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