<< Chapter < Page Chapter >> Page >

Play the wipe effect and increment the counter

One of the statements in Listing 12 calls the play method on the effect object referred to by wipeEffect causing that effect to play. The last statement in Listing 12 incrementsthe effect counter by a value of one. Then control passes to the end of the showHandler method near the bottom of Listing 15.

Code to play the Rotate effect

If the value of the effect counter was 1 when control entered the if-else-if statement in Listing 12, the last four statements in Listing 13 are executed. Otherwise, control passes to the top of Listing 14.

Code to play the rotate effect.

}else if(effectCounter == 1){ rotateEffect.originX = btnB.width/2;rotateEffect.originY = btnB.height/2; rotateEffect.play();effectCounter++;

If the value of the effect counter was 1 when the if-else-if statement began execution, the play method is called on the rotateEffect object by the code in Listing 13.

Establish the center of rotation

Before calling the play method, however, the code in Listing 13 establishes the center of the button as the point around which the button willbe rotated. It was not possible to establish this point when the Rotate effect was configured in Listing 8 because reliable information about the widthand height of the button was not yet available.

Could have used creationComplete

Perhaps a more elegant approach to establishing the center of rotation would have been to register a creationComplete listener on the VBox and to set the values for originX in originY in that handler. However, that seemed like overkill and I decided to do it in Listing 13.

Increment the counter and go to the end of the method

If the last four statements in Listing 13 are executed, the effect counter is incremented by one. Then control passes to the bottom of the method inListing 15.

Code to play the Glow effect

If the value of the effect counter was 2 when control entered the if-else-if statement in Listing 12, the last two statements in Listing 14 are executed.Otherwise, control passes to the top of Listing 15.

Code to play the glow effect.

}else if(effectCounter == 2){ glowEffect.play();effectCounter++;

The last two statements in Listing 14 play the glow effect and increment the effect counter. Then control passes to the bottom of the method in Listing15.

Code to play three effects in parallel

If the value of the effect counter was something other than 0, 1, or 2 whencontrol entered the if-else-if statement in Listing 12, the code in the else clause in Listing 15 is executed.

Code to play three effects in parallel.

}else{ //Play all three effects in parallel.var parallel:Parallel = new Parallel(); parallel.addChild(rotateEffect);parallel.addChild(glowEffect); parallel.addChild(wipeEffect);parallel.play(); //reset the effect countereffectCounter = 0; } //end else} //end showHandler //--------------------------------------------------//} //end class } //end package

An object of the Parallel class

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