Hey, I’ve got a question about refrencing properties from an actionscript object.
If i’ve got the following object named “groups”…
group1
item1 = sampledata1
item2 = sampledata2
item3 = sampledata3
group2
item1 = sampledata4
item2 = sampledata5
item3 = sampledata6
I would access group1/item2 by typing “groups.group1.item2”
How would I create a method, where I can pass in the key in string form, and retrieve the data at that node. For example
groups.group1.item2 would return sampledata2
and
getItem(“group1.item2”); would also return sampledata2
I think this is possible using eval(), but I believe that was removed in AS 3.0 which i’m using. Is there any other way to do this? Thanks.
Use Objects the way you would use hashes.
You can initialize objects this way:
Or using brackets:
Access is done like this:
hope that helps.