引用动作脚本类中的其他影片剪辑

发布于 2024-08-18 15:39:43 字数 181 浏览 2 评论 0原文

我已将影片剪辑的动作脚本代码外部化到单独的类文件中。 该影片剪辑需要引用舞台上的一些其他剪辑。我目前正在做的引用这些剪辑的方法是使用 Movieclip(this.parent).otherclip 但不知何故感觉不对。

是否有更好的方法将所需的引用传递到从构造函数内部的 Movieclip 扩展的类中?或者这里推荐的模式是什么?

I have externalized the actionscript code of a movieclip into a separate class files.
This movieclip requires references to some other clips on the stage. What I am currently doing to reference those clips is by using Movieclip(this.parent).otherclip but somehow that feels wrong.

Is there a better way to pass in the required references into a class extending from Movieclip inside of the constructor? Or what is the recommended pattern here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自我难过 2024-08-25 15:39:43

父影片剪辑也有一个类吗?
如果,也许父类应该管理初始化,它是子类

如果没有,您可以从您正在编写的类调度一个事件,并在父级中监听该事件。

如果事情很复杂并且性能是一个问题,您可以添加函数回调

哈特哈,
乔治

Does the parent movie clip have a class as well ?
If, maybe the parent class should manage initializing it's children.

If not, you could dispatch an event from the class your are writing, and listen for that event in the parent.

If it's something complex and performance is an issue, you could just add function callbacks.

HTH,
George

迷你仙 2024-08-25 15:39:43

尝试 (parent as Object) 无论如何,调度事件方法要好得多。

try (parent as Object) anyway the dispatch event approach is much better.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文