Chapter 12. Effects

Effects are an important part of a Flex application and are one of the most important elements of the Rich in the popular moniker Rich Internet Application. Understanding effects and the effect framework in Flex is important not only for design and implementation, that is, the element effects that the user will see, but also for the aspects that the user will not notice if the effects are implemented correctly, but will certainly notice if the application lags or doesn’t perform garbage collection appropriately. At the core of the effects engine is a system of timers and callbacks that are not all that much different conceptually from this:

var timer:Timer = new Timer(100, 0);
timer.addEventListener(TimerEvent.TIMER, performEffect);
timer.start();

private function performEffect(event:Event):void {
    //effect implementation
}

Of course, the reality of the effect framework is more complex than simply allowing the developer to create an instance of an Effect class and call a play method on it. In reality, the EffectManager class manages all instances of all effects to avoid overtaxing the processor with unnecessary timers and function calls. An effect should be thought of as two distinct elements: the EffectInstance (which contains information about the effect, what it should do, and what elements it will affect) and the Effect class (which acts as a factory, generating the effect, starting it, and deleting it when it has finished).

The playing of an effect consists ...

Get Flex 3 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.