User Guide
250 Creating Effects
Overriding the initEffect() method
The EffectInstance class defines the initEffect() method that you can override in your
custom effect. This method has the following signature:
public initEffect(event:Event):void
where event is the Event object dispatched by the event that triggered the effect.
For example, a user might create an instance of an effect, but not provide all of the
configuration information that is required to play the effect. Although you might be able to
assign default values to all properties within the definition of the effect class, in some cases you
might have to determine the default values at run time.
In this method, you can examine the
Event object and the effect target to calculate values at
run time. For more information on how to create a custom event and an effect trigger, see
“Defining a custom effect trigger” on page 247. As part of that example, you can add
properties to the
Event object passed to the dispatchEvent() method. You can then access
that
Event object, and its additional properties, from the initEffect() method.
By overriding the
initEffect() method, you can also access the target property of the
Event object to reference the target component of the effect. For example, if you must
determine the current x and y coordinates of the component, or its current height and width,
you can access them from your override of the
initEffect() method.