<< Chapter < Page Chapter >> Page >

Even some of the classes that are subclasses of DisplayObject support events that don't involve direct user interaction such as the activate and deactivate events.

Events that don't involve user interaction are usually events that are dispatched because of some change of state within the program. Forexample, it is possible to register event listeners on object properties and cause other objects to be notified when the value of such properties change.

Preview

I will present and explain two programs in the remainder of this lesson. The first program named ActivateEvent01 provides a relatively simple illustration of servicing events that are dispatched independently of directuser interaction.

The second program named Effects03 is somewhat more substantial. It illustrates the servicing of events that are dispatched as a result of directuser interaction as well as events that are dispatched independently of direct user interaction.

Discussion and sample code

A simple MXML file

Both of the programs that I will explain in this lesson use the same simple MXML file shown inListing 1 and also in Listing 14.

Common code for the mxml file.

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"xmlns:cc="CustomClasses.*"><cc:Driver/></mx:Application>

This MXML code simply instantiates a new object of the Driver class in the cc namespace. Beyond that point, all program behavior is controlled by ActionScript code.

The program named ActivateEvent01

This is probably the most fundamental of all event-driven ActionScript programs. This program illustrates the activate and deactivate events. According to the EventDispatcher documentation, the activate event is "Dispatched when the Flash Player or AIR application gains operating system focus andbecomes active."

Similarly, the deactivate event is "Dispatched when the Flash Player or AIR application loses the operating system focus and is becominginactive."

Program screen graphics

The screen output for this program is shown in Figure 1. This output doesn't change during the running of the program.

Program activateevent01 screen graphics.

Missing image
Program ActivateEvent01 screen graphics.

Must run in debug mode

This program uses calls to the trace function to produce output text on the console screen. Therefore, you will need to compile and run theprogram in debug mode in the IDE to get matching results.

Gain and then lose operating system focus

If you start the program in debug mode, click somewhere inside the Flash window and then click somewhere in another window or on the desktop, you will cause the FlashPlayer to first gain and then lose the operating system focus. In other words, on the first click inside the Flash window, the Flash Player willbecome the active program. On the second click in another window, another program will become the active program.

Debug output in the system console

When you do that, output similar to that shown in Figure 2 should appear in the IDE console.

Debug output in the system console.

Missing image
Debug output in the system console.

Questions & Answers

How we are making nano material?
LITNING Reply
what is a peer
LITNING Reply
What is meant by 'nano scale'?
LITNING Reply
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
Maciej
characteristics of micro business
Abigail
for teaching engĺish at school how nano technology help us
Anassong
How can I make nanorobot?
Lily
Do somebody tell me a best nano engineering book for beginners?
s. Reply
there is no specific books for beginners but there is book called principle of nanotechnology
NANO
how can I make nanorobot?
Lily
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
NANO
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





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