Skip to main content
Participating Frequently
May 9, 2008
Question

Reference, not value of a String eval workaround?

  • May 9, 2008
  • 2 replies
  • 397 views
Hi
I'm trying to get some xml into a variable so I can pass it into another object. The problem is I have to construct the xml path with a string comprised of the name of a variable. If AS 3.0 had eval this might work but.. basically how can I get the actual xml:
This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
May 14, 2008
in your xml example you're not using the array operator to resolve a string to an object. you have a string in your xml file that matches the _sceneClass string.

you always need a string when using array notation to resolve a property using array notation. it might not look like a string (like in your example), but it is a string.

with an object you can use:

obj.var1

is the same as

obj["var1"]

but you couldn't use

obj[var1].

you could use:

var2 = "var1";
obj[var2];
kglad
Community Expert
Community Expert
May 9, 2008
flash can resolve strings to objects using array notation. the object must be the child of some parent object that's then used to resolve the string.

so, if _contentXML is your xml object and it's a child of tl, you could use:

jctw769Author
Participating Frequently
May 14, 2008
I had been trying to use the bracket notation, but incorrectly, and thinking it was futile. You gave me a huge help with it, thanks very much. But I found that the object reference needs no quotes if they're already class property or object variables, correct? Also, I found I can reference the object does not have to be the child of some parent object. For instance, where _contentXml is my xml object, and _sceneClass is an ever-changing String that will be part of the xml path I want access to: