Accessibility

Macromedia Flash Article

Building and Testing Components in Macromedia Flash MX 2004


Table of Contents

  1. About Macromedia Flash 2004 Components
  2. Benefits of the New-School Component Architecture
  3. Building Components the Macromedia Flash 2004 Way
  4. Start With an Empty FLA
  5. SWC MetaData Tags
  6. Bind Your Class to the Symbol
  7. Convert to Compiled Clip
  8. Tips and Hints

SWC MetaData Tags

As a component author, you can include various SWC metadata tags in your component class declaration. These tags get processed whenever you create a compiled clip, export a SWC file, or open the Component Definitions panel.

[Bindable]

This tag reveals a property in the Bindings tab of the Component inspector panel. It must precede a property or getter/setter method.

Usage 1: [Bindable(“readonly”)]
Usage 2: [Bindable(param1=“writeonly”, type=”DataProvider”)]
Usage 3: [Bindable]

Note that param1 (String) can have a value of writeonly, readonly, or if null or ommitted, defaults to read and write. And type (string) indicates the type of object this property can bind to.

[ChangeEvent]

Use the ChangeEvent metadata tag to execute one or more component events when you make changes to bindable properties. When an event in the metadata fires, Macromedia Flash informs whatever is bound to the property that the property has changed when a getter or setter function is called. It must precede a property or getter/setter.

Usage: [ChangeEvent("click")]

[ComponentTask]

A component can have one more JSFL files associated with it to perform tasks for this component (in the authoring environment). Use this tag to define this association. The JSFL files interact with the JavaScript API in the Macromedia Flash authoring environment.

[ComponentTask[taskName,taskFile[,otherFile[,…]]]

The tasks pop-up menu appears on the schema tab of the Component Inspector panel. You activate it by using the button on the right side of the dialog box.

[Event]

Use the Event metadata tag to define events that this component will broadcast. Add the Event metadata tag outside of the class definition so that they are bound to the class and not a particular member of the class.

Usage: [Event("click")]

[IconFile]

The filename for the icon that represents this component in the library.

Usage: [IconFile("MyComponent.png")]

The filename can be any valid relative file path. If you have more than one IconFile tag, then only the last occurrence takes effect.

[Inspectable]

Defines an attribute exposed to component users in the Component Definition and Component inspector panels.

name (String): An optional display name for the property. If it is not specified, use the property’s name.

type (String): An optional type specifier. If it is not specified, it defaults to the property’s type.

  • Array
  • Object
  • List
  • String
  • Number
  • Boolean
  • Font Name
  • Color

defaultVaue (String or Number): Required. A default value for the inspectable property.

enumeration (String): Optional. Specifies a comma-delimited string list of legal values for the parameter.

verbose (Number): Optional. A string to group the property into a specific subcategory in the Property Inspector.

listOffset (Number): Optional. Added for backward compatibility with Macromedia Flash MX Components. Used as the default Index into a List value.

variable (String): Optional. Added for backward compatibility with Macromedia Flash MX Components. Used to specify the variable that this parameter is bound to.

category (String): Optional. Groups the property into a specific subcategory in the Property inspector.

[InspectableList]

Subset of items that you want to show up in the property panel. Sometimes there are items that you inherit that you don’t want to expose. This tag allows you to control what is exposed, but the order of the list is not important and has no significance. If this tag is omitted, then all Inspectable properties appear in the Property inspector.