<< Chapter < Page Chapter >> Page >

This code instantiates an object of the Parallel class and adds the three effects as children of that object. Then the code calls the play method on the Parallel object. This causes all three effects to play simultaneously.

Reset the counter

Finally, Listing 15 resets the value of the effect counter back to 0 so that the sequence will begin anew the next time the event handler for the show event is executed.

Play the same effect on multiple targets simultaneously

You can play the same effect on multiple targets simultaneously by setting the targets property on the effect object instead of the target object. The targets property requires an array containing references to the target objects.

Three steps are required

The following steps are required to play an effect in the Flash Player using this approach.

  1. Instantiate and save a reference to an Effect object.
  2. Set properties on the effect object. Be sure to set the target property for a single target or the targets property for multiple targets.
  3. Call the play method on the effect object.

To play multiple effects in parallel or in sequence

  1. Instantiate and save references to two or more Effect objects.
  2. Set properties on the effect objects, being careful to set either the target property or the targets property.
  3. Instantiate a Parallel object or a Sequence object.
  4. Add the effect objects as children of the Parallel object or the Sequence object.
  5. Call the play method on the Parallel object or the Sequence object.

Note that you can also add Sequence objects to Parallel objects and vice versa. Just make certain that you don't try to play two instancesof the same effect on the same object at the same time.

The end of the program

Listing 15 also signals the end of the Driver class and the end of the program.

Run the programs

I encourage you to run these two programs from the web. Then copythe code from Listing 16 through Listing 18. Use that code to create Flex projects. Compile and run the projects.Experiment with the code, making changes, and observing the results of your changes. Make certain that you can explain why your changes behave as theydo.

Resources

I will publish a list containing links to ActionScript resources as a separate document. Search for ActionScript Resources in the Connexions search box.

Complete program listings

Complete listings of the MXML and ActionScript files are provided in Listing 16 through Listing 18 below.

The mxml file used for both programs.

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

The driver class for effects04.

/*Effects04 11/22/09 This program shows how to set the style on an object witha mouseUpEffect trigger and cause the object to glow. */package CustomClasses{ import mx.containers.VBox;import mx.controls.Button; import mx.controls.Label;import mx.effects.Glow; public class Driver extends VBox{//Instantiate and save references to all of the // objects needed by the program.private var title:Label = new Label(); private var button:Button = new Button();private var glowEffect:Glow = new Glow(); //--------------------------------------------------//public function Driver(){//constructor//Set title properties and add to the VBox. title.setStyle("color","0xFFFF00");title.setStyle("fontSize",14); title.text = "Demo mouseUpEffect trigger";addChild(title); button.label = "Click me and watch me glow.";addChild(button); glowEffect.color = 0xFF0000;glowEffect.strength = 255;glowEffect.duration = 10000; button.setStyle("mouseUpEffect",glowEffect);} //end constructor //--------------------------------------------------//} //end class } //end package

Questions & Answers

how to study physic and understand
Ewa Reply
what is conservative force with examples
Moses
what is work
Fredrick Reply
the transfer of energy by a force that causes an object to be displaced; the product of the component of the force in the direction of the displacement and the magnitude of the displacement
AI-Robot
why is it from light to gravity
Esther Reply
difference between model and theory
Esther
Is the ship moving at a constant velocity?
Kamogelo Reply
The full note of modern physics
aluet Reply
introduction to applications of nuclear physics
aluet Reply
the explanation is not in full details
Moses Reply
I need more explanation or all about kinematics
Moses
yes
zephaniah
I need more explanation or all about nuclear physics
aluet
Show that the equal masses particles emarge from collision at right angle by making explicit used of fact that momentum is a vector quantity
Muhammad Reply
yh
Isaac
A wave is described by the function D(x,t)=(1.6cm) sin[(1.2cm^-1(x+6.8cm/st] what are:a.Amplitude b. wavelength c. wave number d. frequency e. period f. velocity of speed.
Majok Reply
what is frontier of physics
Somto Reply
A body is projected upward at an angle 45° 18minutes with the horizontal with an initial speed of 40km per second. In hoe many seconds will the body reach the ground then how far from the point of projection will it strike. At what angle will the horizontal will strike
Gufraan Reply
Suppose hydrogen and oxygen are diffusing through air. A small amount of each is released simultaneously. How much time passes before the hydrogen is 1.00 s ahead of the oxygen? Such differences in arrival times are used as an analytical tool in gas chromatography.
Ezekiel Reply
please explain
Samuel
what's the definition of physics
Mobolaji Reply
what is physics
Nangun Reply
the science concerned with describing the interactions of energy, matter, space, and time; it is especially interested in what fundamental mechanisms underlie every phenomenon
AI-Robot
what is isotopes
Nangun Reply
nuclei having the same Z and different N s
AI-Robot
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