Using ActionScript 2.0 Components |
|
|
|
| Collection Properties > Accessing collection information programmatically > Accessing collection information in a component class (AS) file | |||
In a component's class file, you can write code that interacts with collection items defined during authoring or at runtime.
To access collection item information in a component class file, you can use any of the following approaches.
variable attribute, for which you specify a variable of type mx.utils.Collection. Use this variable to access the collection, as shown in this example:
[Collection(name="LinkButtons", variable="__linkButtons", collectionClass="mx.utils.CollectionImpl", collectionItem="ButtonC", identifier="ButtonLabel")] public var __linkButtons:mx.utils.Collection;
Collection.getIterator() method, as shown in this example:
var itr:mx.utils.Iterator = __linkButtons.getIterator();
Iterator.next() method returns an Object, so you must define the type of your collection item, as shown in this example:
while (itr.hasNext()) {
var button:ButtonC = ButtonC(itr.next());
...
}
item.label = button.ButtonLabel;
if (button.ButtonLink != undefined) {
item.data = button.ButtonLink;
}
else {
item.enabled = false;
}
|
|
|
|