Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get list of properties in an object in Actionscript?

I have a dataprovider and a filterfunction for my array that's assigned to my dataprovider.

How can I get a list of the properties that are in each row of the dataprovider (item.data) as it gets passed to the filterfunction?

For instance, if my object contained:

  • Object
    • name
    • email
    • address

Then I would want, in my filterfunction to be able to look at name, email and address. Unfortunately, I don't know what these properties will be before hand.

Any ideas?

like image 375
GeoffreyF67 Avatar asked Dec 16 '08 19:12

GeoffreyF67


2 Answers

If it's a dynamic object I believe you can just do something like this:

var obj:Object; // I'm assuming this is your object  for(var id:String in obj) {   var value:Object = obj[id];    trace(id + " = " + value); } 

That's how it's done in AS2, and I believe that still works for dynamic objects in AS3. I think the properties that it will show is more limited on non-dynamic objects.

like image 171
Herms Avatar answered Sep 22 '22 16:09

Herms


flash.utils.describeType(value:*) will also give you a list of properties on an object.

like image 25
Joel Hooks Avatar answered Sep 21 '22 16:09

Joel Hooks