Flash CS4 Professional ActionScript 2.0

Collection Properties

When you create a new custom component in Flash, you can make property values available for editing by the user. These properties are called collection properties. The property values can be edited by the user in the Values dialog box (opened from a text box within the Parameters tab for your component).

Components usually include functionality for a specific task, while remaining flexible for a range of requirements by the component user. For a component to be flexible, the properties within the component need to be flexible (in other words, for some components, the properties can be changed by the component user, as well as by the property values).

Collection properties enable you to create an indeterminate number of editable properties in an object model. Flash provides a Collection class to help you manage those properties through the Component inspector.

Specifically, the Collection class is a helper class used to manage a group of related objects, each called a collection item. If you define a property of your component as a collection item and make it available to users through the Component inspector, they can add, delete, and modify collection items in the Values dialog box while authoring.

The Values dialog box

You define collections and collection items as follows:

  • Define a collection property using the Collection metadata tag in a component's ActionScript file. For more information, see About the Collection tag.
  • Define a collection item as a class in a separate ActionScript file that contains its own inspectable properties.

In Flash, Collections make it easier for you to manage groups of related items programmatically. (In previous versions of Flash, component authors managed groups of related items through multiple programmatically synchronized arrays).

In addition to the Values dialog box, Flash provides the Collection and Iterator interfaces to manage Collection instances and values programmatically. See Collection interface and Iterator interface in ActionScript 2.0 Components Language Reference.

This chapter contains the following sections: