Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 232

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

Example: Defining a simple effect
To define a simple custom effect, you create a factory class from the
instance class from the mx.effects.EffectInstance class. The following example shows an effect
class that uses a
Sound
example is a simplified version of the
package myEffects
{
// myEffects/MySound.as
import mx.effects.Effect;
import mx.effects.EffectInstance;
import mx.effects.IEffectInstance;
public class MySound extends Effect
{
// Define constructor with optional argument.
public function MySound(targetObj:Object = null) {
// Call base class constructor.
super(targetObj);
// Set instanceClass to the name of the effect instance class.
instanceClass= MySoundInstance;
}
// This effect modifies no properties, so your
// override of getAffectedProperties() method
// returns an empty array.
override public function getAffectedProperties():Array {
return [];
}
// Override initInstance() method.
override protected function initInstance(inst:IEffectInstance):void
{
super.initInstance(inst);
}
}
}
The
statement in your class specifies that you should deploy it in a directory called
package
myEffects. In this example, you place it in the subdirectory of the directory that contains your
Flex application. Therefore, the namespace definition in your Flex application is
xmlns:MyComp="myEffects.*"
"Compiling Components," on page
232
Creating Effects
object to play an embedded MP3 file when a user action occurs. This
SoundEffect
. For more information on deployment, see
63.
Effect
class that ships with Flex.
base class, and the
Chapter 6,

Advertisement

Table of Contents
loading

Table of Contents