简体   繁体   English

AS3检查类名是否

[英]AS3 check if class name is

I want to know if a Class is the main stage, in other words... 我想知道一个班级是否是主舞台,换句话说......

if it is "ThisName" then... 如果是“ThisName”那么......

My code is: 我的代码是:

MainStage = this.parent as MovieClip;
trace("scroll Stage: " + MainStage); // output: scroll Stage: [object Main_Activate]

but how would I write it this way? 但是我怎么用这种方式写呢?

if(MainStage == [object Main_Activate])
then run my code.

In this last example [object Main_Activate] is getting errors. 在最后一个示例中,[对象Main_Activate]出现错误。

您可以使用is运算符

if (this.parent is Main_Activate)

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

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