<< Chapter < Page | Chapter >> Page > |
The overridden play method produces the desired effect
Later on you will see that the driver class for this program instantiates an object of the custom effect class and calls the play method on that object. At that point, the driver class will be calling the method thatbegins in Listing 9.
Set the required properties on the three standard effects
Listing 9 uses the values that were stored in the variables in Listing 7 by the initInstance method in Listing 4 to set the required properties for each ofthe three individual effects that will be combined to produce this custom effect.
Ordinarily, you might think that this could have been accomplished in the constructor for the class. However, the values in the variables in Listing 7aren't stable until the constructor has finished constructing the object. Therefore, it is necessary to defer the assignments in Listing 9 until after theconstruction of the object is complete.
Play the three effects in parallel
You learned how to use an object of the Parallel class to play two or more effects in parallel in the earlier lesson titled Events, Triggers, and Effects .
//Play all three effects in parallel.
var parallel:Parallel = new Parallel();parallel.addChild(rotateEffect);
parallel.addChild(glowEffect);parallel.addChild(wipeEffect);
parallel.play();} //end play
//--------------------------------------------------//} //end class
} //end package
Therefore, you shouldn't have any difficulty understanding the code in Listing 10.
Steps required to create a custom effect
You must define a factory class and an instance class. The following steps are required to create and prepare the factory class:
Define and prepare the instance class
Having defined the factory class using the steps listed above, define the instance class by performing the following steps:
The end of the CustomEffectInstance class
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with actionscript' conversation and receive update notifications?