简体   繁体   English

AS3从静态方法获取当前类名

[英]AS3 Get the current class name from a static method

i have to read the current class name inside a static method. 我必须在静态方法中读取当前的类名。 For non-static method it's easy i just call getQualifiedClassName(this) but inside a static method this is off course invalid. 对于非静态方法,我很容易调用getQualifiedClassName(this),但在静态方法中,这当然是无效的。 Any idea ? 任何的想法 ?

Thanks 谢谢

您可以在类的静态方法中使用getQualifiedClassName(prototype.constructor)

You don't have a direct way of doing this. 你没有这样做的直接方法。 If is just inside one class that you need this, you can try to add a static member holding a reference to the class. 如果只是在您需要的一个类中,您可以尝试添加一个静态成员来保存对该类的引用。

static private const CLASS:Object = YourReflectedClass;

then, just use that in your static method: 然后,只需在静态方法中使用它:

protected static function doReflection(): void {
   var className:String = getQualifiedClassName(CLASS);
}

It would be helpful to know more about the use and the setup. 了解有关使用和设置的更多信息会很有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM