卸载子SWF儿童SWF的最后一帧 [英] Unload child swf on last frame of child swf

查看:100
本文介绍了卸载子SWF儿童SWF的最后一帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用AS3 我在我的codeA按钮停止并删除SWF,但我想有除了卸载子SWF,当它播放时,将自动最后一帧。 - 不可以使用按钮

Using AS3 I have in my code a button to stop and remove the swf, but I would like to have in addition to unload a child swf when it plays it's last frame automatically - not using a button.

下面是我的主时间轴上code:

Here is my code on the main timeline:

VAR装载机:装载机; VAR接近:关闭;

var loader:Loader; var closer:close;

norton_btn.addEventListener(MouseEvent.CLICK,NortonDemo); 功能NortonDemo(E:MouseEvent)方法:无效 {  VAR REQ:的URLRequest =新的URLRequest(norton.swf);  装载机=新的Loader();  loader.load(REQ);  container_mc.addChild(装载机);  接近=新的close();  closer.x = 415;  closer.y = -294;  的addChild(接近);  closer.addEventListener(MouseEvent.CLICK,closeNortonDemo);

norton_btn.addEventListener(MouseEvent.CLICK, NortonDemo); function NortonDemo(e:MouseEvent):void { var req:URLRequest = new URLRequest("norton.swf"); loader = new Loader(); loader.load(req); container_mc.addChild(loader); closer = new close(); closer.x = 415; closer.y = -294; addChild(closer); closer.addEventListener(MouseEvent.CLICK, closeNortonDemo);

}

功能closeNortonDemo(E:MouseEvent)方法:无效 {

function closeNortonDemo(e:MouseEvent):void {

closer.removeEventListener(MouseEvent.CLICK,closeNortonDemo);  removeChild之(接近);  container_mc.removeChild(装载机);  loader.unloadAndStop();

closer.removeEventListener(MouseEvent.CLICK, closeNortonDemo); removeChild(closer); container_mc.removeChild(loader); loader.unloadAndStop();

}

///////////////////////////

///////////////////////////

现在,我需要什么,添加或更改此code,并加入到code NortonDemo的最后一帧来完成我想做什么?

Now, what do I need to add or change to this code and add to the code on the last frame of NortonDemo to accomplish what I want to do?

谢谢!

推荐答案

您需要删除加载的SWF时,它扮演的最后一帧?
我会做这样yhis:

you need to delete loaded swf when it plays the last frame?
i'd do it like yhis:

loader.contentLoaderInfo.addEventListener(Event.INIT, onInit);
addChild(loader);
loader.load(new URLRequest("norton.swf"));

private function onInit(e:Event):void {
   (loader.getChildAt(0) as MovieClip).addEventListener(Event.ENTER_FRAME, onFrame);
}

private function onFrame(e:Event):void {
    if((loader.getChildAt(0) as MovieClip).totalFrames == (loader.getChildAt(0) as MovieClip).currentFrame){
        (loader.getChildAt(0) as MovieClip).removeEventListener(Event.ENTER_FRAME, onFrame);//the only thing that might cause a problem imho
         loader.removeChildAt(0);
         loader.unload();
    }
}

这篇关于卸载子SWF儿童SWF的最后一帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆