Actionscript adding an element to object in arraycollection

211 views Asked by At

How can I add an element to object in arraycollection?

Example code:

var mycollection:ArrayCollection = new ArrayCollection();
var myobject:Object=new Object();
myobject["label"]="My Label";
myobject["data"]="My data";
mycollection.addItem(myobject);

If later on, I want to add extra element, let say "date" to myobject in mycollection, how can I do it?

Thank you.

1

There are 1 answers

0
terry.bondy On

My experience is with Flex more than Flash...

If you still have the reference to myobject, it is as simple as:

myobject["date"]= new Date();

If you want to trigger viewers of the collection to update their views of the collection, you would also likely have to do:

mycollection.itemUpdated(myobject, "date", null, myobject["date"]);

Cheers, Terry