kingd
09-14-2010, 03:15 PM
I have an ArrayCollection from which I want to create checkboxes that are divided into sections with headers, like below:
FICTION
[] The Sleeper Awakes -- H.G. Wells [] The Time Machine -- H.G. Wells
[] The Invisible Man -- H.G. Wells [] War of the Worlds -- H.G. Wells
I've tried the following, but was unable to addElements to the list. Anyone know what I can do to addElements and create the list?
...
var books:ArrayCollection = new ArrayCollection([{category: "fiction", title: "The Time Machine", author: "H.G. Wells"},...]);
var list:List = new List();
list.layout = new TileLayout();
for (var i:int = 0; i < books.length; i++)
{
var checkBox:CheckBox = new CheckBox();
checkBox.id = "book";
checkBox.label = String(books.getItemAt(i).title);
list.addElement(checkBox);
// Error -- 1061: Call to a possibly undefined method addElement through a reference with static type spark.components:List.
}
booksPanel.addElement(list);
FICTION
[] The Sleeper Awakes -- H.G. Wells [] The Time Machine -- H.G. Wells
[] The Invisible Man -- H.G. Wells [] War of the Worlds -- H.G. Wells
I've tried the following, but was unable to addElements to the list. Anyone know what I can do to addElements and create the list?
...
var books:ArrayCollection = new ArrayCollection([{category: "fiction", title: "The Time Machine", author: "H.G. Wells"},...]);
var list:List = new List();
list.layout = new TileLayout();
for (var i:int = 0; i < books.length; i++)
{
var checkBox:CheckBox = new CheckBox();
checkBox.id = "book";
checkBox.label = String(books.getItemAt(i).title);
list.addElement(checkBox);
// Error -- 1061: Call to a possibly undefined method addElement through a reference with static type spark.components:List.
}
booksPanel.addElement(list);