AS3 范围问题,如何在包/类中动态创建新的 MC?
非常感谢您抽出时间!这是我的问题,...
public function addNewMc():void{
var newMC:MovieClip= new MovieClip();
this.addChild(newMC);
}
public function removeOldMc(newMC):void{
this.removeChild(newMC);
}
如何在方法中创建一个新的 MovieClip,该方法可以在整个类中使用,而无需在类的顶部定义它?并且为了加分,不使用退货。
如果第一个函数 addNewMc 返回值 newMC ,并将其传递给任何其他方法,我就可以让它工作......但对于我正在写的内容,我希望用其他东西来用完我的返回值。谢谢!
Thanks very much for your time! Here is my question,...
public function addNewMc():void{
var newMC:MovieClip= new MovieClip();
this.addChild(newMC);
}
public function removeOldMc(newMC):void{
this.removeChild(newMC);
}
How can I create a new MovieClip within a method, which can be used throughout the class, without defining it at the top of the class? And for extra points, without using return.
I can get it to work, if the first function addNewMc returns the value newMC, and passing that to any other methods... but for what I am writing, I hope to use up my return with something else. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知道我是否完全理解您的意思,但听起来您想要访问动态创建的影片剪辑而不显式定义它?!对吗?
如果是这样,那么您可以执行现在的操作,但添加一个检索方法:
您还可以向动态创建的影片剪辑添加一个名称属性:
然后您可以像这样检索:
再次不知道我是否理解您的确切意思要求
干杯
埃里克;)
Don't know if I'm understanding you completely but it sounds like you want access to a dynamically created Movieclip without explicitly defining it?! is that right?
If so, then you could do what you have now but add a method for retrieval:
You could also add a name property to the dynamically created movieclip:
you could then retrieve like this:
Again don't know if I'm understanding your exact requirements
cheers
erick ;)