<< Chapter < Page Chapter >> Page >

I will break this program down and explain it in fragments. Aside from the MXML file shown in Listing 14, the program consists of a single class named Driver . A complete listing of the Driver class file is provided in Listing 16 near the end of the lesson.

Beginning of the class named Driver

The Driver class begins in Listing 4. Note that this class extends the Panel class, causing this program to have the same overall appearance as the program provided in the documentation .

Beginning of driver class for effects03.

package CustomClasses{ import flash.events.MouseEvent;import mx.containers.ControlBar; import mx.containers.Panel;import mx.controls.Button; import mx.controls.Image;import mx.controls.TextArea; import mx.effects.Resize;import mx.events.EffectEvent; import mx.events.FlexEvent;public class Driver extends Panel{ //Instantiate and save references to all of the// objects required by the program. private var resize:Resize = new Resize();private var textOut:TextArea = new TextArea(); private var image:Image = new Image();private var bar:ControlBar = new ControlBar(); private var startButton:Button = new Button();private var pauseButton:Button = new Button(); private var resumeButton:Button = new Button();private var reverseButton:Button = new Button(); private var endButton:Button = new Button();private var resetButton:Button = new Button();

In addition to containing all of the required import directives, the code in Listing 4 instantiates and saves references to all of the objects required bythe program.

Beginning of the constructor for Effects03

The constructor begins in Listing 5.

Beginning of the constructor for effects03.

public function Driver(){//constructor this.title="Demonstration of the Resize effect.";this.percentWidth = 100; this.percentHeight = 100;this.addEventListener(FlexEvent.CREATION_COMPLETE,creationCompleteHandler);

The code in Listing 5 sets several properties on the Panel object, which is the object with the light gray background shown in Figure 4. The Panel object is displayed in the browser window, which has a slightly darker gray background color in Figure 4.

Register an event listener

The last statement in Listing 5 registers an event listener named creationCompleteHandler to service creationComplete events dispatched by the Panel object.

As you will see later, the event handler causes the text "Creation Complete!" to be displayed in a TextArea object near the top of the Panel in Figure 4 when the Panel object and all of its children have been constructed, initialized, and drawn.

Prepare the TextArea object and add it to the Panel

Listing 6 sets some properties and some styles on the TextArea object and adds it near the top of the Panel as shown in Figure 4.

Prepare the textarea object and add it to the panel.

textOut.percentWidth = 100;//percent textOut.height = 100;//pixelstextOut.setStyle("color","0x0000FF"); textOut.setStyle("fontSize",14);textOut.text = "Use the Buttons to control " + "the size of the image.";addChild(textOut);

Questions & Answers

what is phylogeny
Odigie Reply
evolutionary history and relationship of an organism or group of organisms
AI-Robot
ok
Deng
what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

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