catObj is appended to the array in the first position so that the Combo
box can display ALL as the first option in the list
Chad Gray wrote:
I am reading the 'Adobe Flex 2 Training from the Source' book and have
a question as to why they used an object and not array. Page 118 for
those that have the book.
What they are doing is taking an array (categories) and appending a
new row to it Name=All and CategoryID=0.
Is there any advantage/disadvant age to setting catObj as an object
and not array? I would think you would want them to be the same thing.
// define new var catObj as an object
var catObj:Object = new Object();
// set the new object var NAME to ALL and set the CATEGORYID to 0
catObj.name = "All";
catObj.categoryID = 0;
// now use addItemAt to append the catObj object to the categories
array at the 0 position
categories.addItemA t(catObj, 0);
The book is good, but the OOP stuff when making your own actionscript
classes in lesson 5 kind of confused me. Hopefully I will fully
understand what they did as I learn more about AS.