Groups | Blog | Home
all groups > flash actionscript > may 2005 >

flash actionscript : Dynamic property name


crewr NO[at]SPAM daydots.com
5/6/2005 12:03:18 PM
Sorry for the noobQ but I'm trying to translate a bit of syntax into
actionscript.

In ASP, I can use myval = request("carrot")
In AS2, I need to do something similar with loadvars froma text file.
We read in the data and pull out this.carrot and this.cucumber but what
I need to do is pull out this("carrot") because the key is built
dynamicly.

Does anyone know the syntax for accessing a property by a variable
name?
crewr NO[at]SPAM daydots.com
5/6/2005 12:09:56 PM
Actually, I just figured it out! eval().

I had tried:
x="carrot"
myval=this.eval(x)

which should have been:
myval=eval("this." + x)
AddThis Social Bookmark Button