CURRENT PROJECTS
loading
[Collection (name="options", variable="optionParms", collectionClass="mx.utils.CollectionImpl", collectionItem="Option", identifier="value")] public var optionParms:mx.utils.Collection; public var optionsRow:mx.utils.CollectionImpl;The variable tag defines the end variable the "Collection" will be stored in also known as the container. The collectionClass tag defines the actual class definition with which the "Collection" variable will be instantiated as. As far as I understand the mx.utils.CollectionImpl will only with in this [Collection] parameter with Flash. The collectionItem tag defines the instantiated container object/class for each "Item" in the "Collection". In this case "Option" is a simple class as follows:
class Option { [Inspectable(type="String", defaultValue="value")] var value:String; [Inspectable(type="String", defaultValue="option")] var option:String; };The identifier tag is the index/key of the "Item" object that will appear as the identifier of each "Item" in the "Collection". In other words, I used the "value" as my identifier which means in the parameter edit screen in the Flash IDE each "Item" in the "Collection" will display that item's "value" value (heh) as the key in the collection for said item. This sounds confusing as heck, but just set the identifier as one of the variable names in the collectionItem class and you'll see how it affects the parameter editing.
// this.optionParms is the instance name assigned to the component on the stage var collectParms:Iterator = this.optionParms.getIterator(); while (collectParms.hasNext()) { this.options.push(collectParms.next()); // tmpObj is not scrictly cast because the iterator can contain any datatype var tmpObj = collectParms.next(); // but let us just output the two variables present in the expected collection item trace("value: " + tmpObj.value + " & option: " + tmpObj.option); }