Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

flex3 - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...