如何获取 class 名称作为字符串?
How to get class name as string?
如何获取字符串中的 class 名称?
我试过这个:
Type.getClassName(this));
这是当前的位置 class 我在其中,但出现错误:
com.SubWidget should be Class<Dynamic>
有什么帮助吗?
您应该将 Class
传递给 Type.getClassName
。所以,首先使用 Type.getClass
获取它,如下所示:
class Test {
static function main() new Test();
function new()
{
var className = Type.getClassName(Type.getClass(this));
trace('Current class name = $className');
}
}
如何获取字符串中的 class 名称?
我试过这个:
Type.getClassName(this));
这是当前的位置 class 我在其中,但出现错误:
com.SubWidget should be Class<Dynamic>
有什么帮助吗?
您应该将 Class
传递给 Type.getClassName
。所以,首先使用 Type.getClass
获取它,如下所示:
class Test {
static function main() new Test();
function new()
{
var className = Type.getClassName(Type.getClass(this));
trace('Current class name = $className');
}
}