Defining component parameters

When building a component, you can add parameters that define its appearance and behavior. The most commonly used parameters appear as authoring parameters in the Component inspector and Property inspector. You can also set all inspectable and collection parameters with ActionScript. You define these properties in the component class file by using the Inspectable tag (see About the Inspectable tag).

The following example sets several component parameters in the JellyBean class file, and exposes them with the Inspectable tag in the Component inspector:

class JellyBean{
    // a string parameter
    [Inspectable(defaultValue="strawberry")]
    public var flavorStr:String; 
    
    // a string list parameter
    [Inspectable(enumeration="sour,sweet,juicy,rotten",defaultValue="sweet")]
    public var flavorType:String; 
    
    // an array parameter
    [Inspectable(name="Flavors", defaultValue="strawberry,grape,orange", verbose=1, category="Fruits")] 
    var flavorList:Array; 
    
    // an object parameter
    [Inspectable(defaultValue="belly:flop,jelly:drop")]
    public var jellyObject:Object;
    
    // a color parameter
    [Inspectable(defaultValue="#ffffff")]
    public var jellyColor:Color;

    // a setter
    [Inspectable(defaultValue="default text")]
    function set text(t:String) {
}
}

You can use any of the following types for parameters:

NOTE

The JellyBean class is a theoretical example. To see an actual example, look at the Button.as class file that installs with Flash in the language/First Run/Classes/mx/controls directory.