Flex - Use Variables for Object Attribute Names

Posted by Immanuel on Stack Overflow See other posts from Stack Overflow or by Immanuel
Published on 2010-03-19T07:17:39Z Indexed on 2010/03/19 7:21 UTC
Read the original article Hit count: 131

Filed under:
|
|

How do you use variables to access Object attributes?

Suppose I have an Object declared as follows,

var obj:Object = new Object;
obj.Name = "MyName";
obj.Age = "10";

How would i do something like this,

var fieldName:String = "Name";
var fieldAge:String = "Age";
var Name_Age:String = obj.fieldName + " ," + obj.fieldAge;

The code above treats 'fieldName' and 'fieldAge' as attribute name itself. I want to treat the same as a variable, and map the value associated with the variable as the Object attribute name.

© Stack Overflow or respective owner

Related posts about flex

Related posts about actionscript-3