加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

actionscript-3 – `root`在不同的地方发生变化

发布时间:2020-12-13 23:07:52 所属栏目:Linux 来源:网络整理
导读:在ActionScript 3中,我是 read,根变量引用了Document Class的一个实例. 在我的文档类构造函数中,跟踪(this == root)返回true.稍后在构造函数中,调用另一个类的构造函数.但是,此构造函数声明root为null.最后,从事件监听器的跟踪给出了root是[object Stage]的
在ActionScript 3中,我是 read,根变量引用了Document Class的一个实例.

在我的文档类构造函数中,跟踪(this == root)返回true.稍后在构造函数中,调用另一个类的构造函数.但是,此构造函数声明root为null.最后,从事件监听器的跟踪给出了root是[object Stage]的结果.

我的目标是拥有一个Document Class的单??个实例(在MainGame.as中),并且能够在我的ActionScript程序中将其称为(root作为MainGame).我怎样才能做到这一点?

如果重要,我的所有代码都在默认包中.

谢谢!

解决方法

将DisplayObject添加到显示列表后,DisplayObject的根特性将成为对Document Class的引用.您可以继续使用root,但请注意,只有显示列表中的对象才有效.

You can read more about root here:

The root property of the Stage object is the Stage object itself. The root property is set to null for any display object that has not been added to the display list,unless it has been added to a display object container that is off the display list but that is a child of the top-most display object in a loaded SWF file.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读