get string representation of a variable name in as3

后端 未结 4 1569
日久生厌
日久生厌 2020-12-22 10:52

any way of doing this is as3?

for example, if I have a var dog:String, how can I get \"dog\" out of that variable?

Looking into reflection to d

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-22 11:14

    Sounds like you don't want to "get" the string representation of a variable name, but rather set the variable based on a string.

    To set a variable that you have its name as a string you can do this:

    this['dog'] = 'value of the dog var';
    

提交回复
热议问题