User Guide

188 Collection Properties
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” on page 157.
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 (Flash
Professional only)” and “Iterator interface (Flash Professional only)” in the Components
Language Reference.
This chapter contains the following sections:
Defining a collection property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Simple collection example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Defining the class for a collection item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .191
Accessing collection information programmatically . . . . . . . . . . . . . . . . . . . . . . . . . . .191
Exporting components that have collections to SWC files. . . . . . . . . . . . . . . . . . . . 194
Using a component that has a collection property . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Defining a collection property
You define a collection property by using the Collection tag in a component’s ActionScript
file. For more information, see About the Collection tag” on page 157.
To define a collection property:
1. Create a FLA file for your component. See “Creating a component movie clip”
on page 138.
2. Create an ActionScript class. See “Creating the ActionScript class file” on page 143.
3. In the ActionScript class, insert a Collection metadata tag. For more information, see
“About the Collection tag” on page 157.
4. Define get and set methods for the collection in the component’s ActionScript file.
NOTE
This section assumes that you know how to create components and inspectable
component properties.