<< Chapter < Page Chapter >> Page >

If you have been studying this series of lessons from the beginning, you shouldn't find anything in Listing 6 that you don't understand.

Configure an Iris effect for the bottom button

Listing 7 configures an Iris effect that will be played each time the bottom button in Figure 3 is hidden.

Configure an iris effect for the bottom button.

irisEffect.duration = 2000; irisEffect.addEventListener(EffectEvent.EFFECT_END,endEffectHandler);btnB.setStyle("hideEffect",irisEffect);

Note that the bottom button in Figure 3 is referred to by the variable named btnB and the top button in Figure 3 is referred to by the variable named btnA .

The code in Listing 7 is essentially the same as the code that I explained in the earlier program named Effects04.

Configure three different effects targeted to the bottom button

Listing 8 configures three different Effect objects that will be played individually and in combination when the bottom button in Figure 3 isshown.

Configure three different effects targeted to the bottom button.

//Configure a wipe effect that may be played // when btnB is shown.wipeEffect.target = btnB; wipeEffect.showTarget = true;wipeEffect.duration = 2000; //Configure a rotate effect that may be played// when btnB is shown. rotateEffect.target = btnB;rotateEffect.angleFrom = 0; rotateEffect.angleTo = 360;rotateEffect.duration = 2000;//Configure a glow effect that may be played // when btnB is shown.glowEffect.target = btnB; glowEffect.color = 0xFFFF00;glowEffect.duration = 4000; glowEffect.inner = true;glowEffect.strength = 255; } //end constructor

Different effects require different properties

The three Effect objects were instantiated in Listing 5. Different types of effects require that different types of properties be set.However, one property that is common for all types of effects when using this approach is to specify the target component on which the effect is to be played.

(Note that it isn't necessary to explicitly specify the target for the earlier approach shown in Listing 7. In that case, the target is theobject on which the setStyle method is called.)

I will leave it as an exercise for the student to go into the documentation and gain an understanding of the behaviors imparted by the different propertyvalues in Listing 8.

Listing 8 also signals the end of the constructor.

A click event handler on the bottom button

Let's begin by disposing of the code that is executed when the bottom button is clicked. A click event handler was registered on thebottom button ( btnB ) in Listing 6. That event handler is shown in Listing 9.

A click event handler on the bottom button.

private function btnBhandler(event:MouseEvent):void{ btnB.visible = false;} //end btnBhandler

A hideEffect trigger

The method shown in Listing 9 is executed each time the user clicks the bottom button. The method sets the visible property of the bottom button to false. This causes the bottom button to dispatch a hide event, which in turn results in a hideEffect trigger. As you saw in Listing 7, this causes the program to play an Iris effect to hide the button.

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