Flash CS4 Professional ActionScript 2.0

Exporting components that have collections to SWC files

When you distribute a component that has a collection, the SWC file must contain the following dependent files:

  • Collection interface
  • Collection implementation class
  • Collection item class
  • Iterator interface

Of these files, your code typically uses the Collection and Iterator interfaces, which marks them as dependent classes. Flash automatically includes dependent files in the SWC file and output SWF file.

However, the collection implementation class (mx.utils.CollectionImpl) and component-specific collection item class are not automatically included in the SWC file.

To include the collection implementation class and collection item class in the SWC file, you define private variables in your component's ActionScript file, as the following example shows:

// collection item class
private var collItem:CompactDisc;
// collection implementation class
private var coll:mx.utils.CollectionImpl;

For more information on SWC files, see Understanding SWC files.