The Life and Times in Carrigaline: July 2008

Tuesday, July 22, 2008

The ActionScript 3.0 Documentation is Muck

Imagine, you're relatively new to Flex. You try to create an array of objects. From your Java days, you remember the java.util library contains ArrayList, which fits the bill perfectly. Now, you go to the Flex documentation, mx.collections, expecting to find something similar. The LiveDocs contain nothing, so you try Google, which give the suggestion of using mx.collections.ArrayList.

Hold on, didn't you just read the ActionScript documentation and there was no mention of ArrayList? For fun, you try importing mx.collection.ArrayList, creating an ArrayList, populating it and then print the length of the array.

import mx.collections.ArrayList;
import mx.controls.Alert;

var theList : ArrayList = new ArrayList();
theList.addItem(new Object);
theList.addItem(new Object);
theList.addItem(new Object);

Alert.show(theList.length.toString());

Surprisingly, this compiles and outputs 3 as the expected result, despite the fact there is no documentation to suggest it would work.

Labels: , , ,