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

what are the products of Nano chemistry?
Maira Reply
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
learn
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
learn
Preparation and Applications of Nanomaterial for Drug Delivery
Hafiz Reply
Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
Jyoti Reply
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
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
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
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
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