[英]AS3 Flash - How to remove dynamically created MovieClip from different function?
[英]AS3 - How to call a function in the root from a nested - dynamically loaded movieclip?
有谁知道使用AS3从动态加载的动画片段(使用addchild加载)在根中触发功能的最佳方法,我知道以根为目标不是这样做的最佳方法吗?
谢谢保罗
DanielB有一点,这并不是最好的设计...加载电影时可以设置调用函数的对象。 例如,这可以通过多种方式完成。
private var _functionCaller:MovieClip;
private function onLoadComplete(event:Event):void
{
_functionCaller = this.parent; // or this.parent.parent or whatever else
}
private function callExternalFunction():void
{
if( _functionCaller != null )
_functionCaller.execute();
}
更好的方法可能是使用事件来通知您的根调用函数...
private var _dispatcher:EventDispatcher;
//this function will be called from the parent
public function init(dispatcher:EventDispatcher):void
{
_dispatcher = dispatcher
}
private function callExternalFunction():void
{
// You could also create a Custom Event
if( _dispatcher != null )
_dispatcher.dispatchEvent("call external function");
}
您应该考虑一下自己的概念。 您加载的SWF应该从加载的电影中调用一个函数才能正常工作吗? 这样加载的电影将永远不会独立运行?
您应该在加载程序(父级)swf中实现所有功能。 加载器电影知道他要加载的内容,因此也许他可以在已加载的剪辑上调用函数。 但是相反的方法就是糟糕的设计。
您可以对已加载的电影执行COMPLETE
(加载)或ADDED_TO_STAGE
,并以这种方式实现功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.