得到的字符串再在AS3变量名的presentation字符串、变量名、presentation

2023-09-08 11:05:37 作者:人生,常态

任何方式这样做的是AS3?

any way of doing this is as3?

例如,如果我有一个 VAR狗:字符串,我怎么能得到狗指出,变量

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

展望反映要做到这一点,但我们有了一个更简单的方法

Looking into reflection to do this, but there's got to be an easier way

- A

推荐答案

希望这有助于。

class A {
   var dog:String = "something";
   var cat:String = "eatdog";
}

function getVars(obj:*):void
{
    for(var i:* in obj){
        trace( i + " : " + obj[i]);
        // this will trace all properties of object.
        // dog : somthing
        // cat : eatdog
    }
}