AS3将MovieClip传递给super
我有一个宇宙飞船 movieclip
,里面有一个movieclip
炮塔。
Spaceship 扩展
Unit 类
,我想在其中旋转炮塔。
在我的 Spaceship 构造函数中,我使用 super(this.turret); ,但这始终返回 null 。
传递其他变量是可行的,并且在调用 super()
之前,我可以成功跟踪 this.turret
那为什么我不能将其传递给 super 呢?我该如何解决这个问题?
[编辑] 也许这与调用 super() 时炮塔不可用/添加到舞台有关?如果是这样,我该如何处理并得到它“单位”呢?
I have a Spaceship movieclip
, with a movieclip
Turret inside.
Spaceship extends
the Unit class
, where I want to rotate the Turret.
In my Spaceship constructor
, I use super(this.turret);
but this always returns null
.
Passing other variables works, and before calling super()
, I can successfully trace this.turret
So why can't I pass it to super? And how can I fix this?
[edit]
Perhaps it has something to do with the turret not being available/added to stage yet when super() is called? If so, how could I deal with that and get it "Unit" anyways?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您将
turret
传递到构造函数
时,您只是传递对具有该实例名称的MovieClip
的引用。Unit 构造函数
对参数做什么?我猜你的Unit
类不应该有炮塔变量。更新1:
When you pass
turret
into theconstructor
you are only passing a reference to theMovieClip
with that instance name. What does theUnit constructor
do with the parameter? I guess that yourUnit
class are not supposed to have a turret variable.UPDATE 1: