AS3停止外部SWF [英] AS3 Stop external swf

查看:323
本文介绍了AS3停止外部SWF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我加载外部SWF到一个影片剪辑,我希望它停止,直到我选择玩。目前,它起着后立即加载。

Hi I'm loading an external swf into a MovieClip, and I want it to stop until I choose to play. Currently it plays upon loading immediately.

var mc:MovieClip;

var swfLoader:Loader = new Loader();
swfLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, eventLoaded); 
var request:URLRequest;
request = new URLRequest("external.swf");
swfLoader.load (request);

function        eventLoaded(e:Event): void
{
   mc = e.target.content as MovieClip;
// does not stop the clip
   mc.Stop ();
}

于是,我尝试添加一个Event.ENTER_FRAME的影片剪辑,并停止在那里,将停止,但它会播放第一帧。有没有办法让当加载,直到我选择玩它留停?

So I tried adding a Event.ENTER_FRAME to the movieclip and stop it there, that will stop but it will play the first frame. Is there a way to get it to stay stopped when loaded until I choose Play?

推荐答案

它实际上是非常接近约亨什么希尔格斯建议。然而,在这种情况下,你想要的事件居然是 INIT ,而不是完全 INIT 当内容尚未完全加载,但已经可以使用(并开始发挥自己)被触发。

It's actually very close to what Jochen Hilgers suggested. However, in this instance, the event you want is actually INIT instead of COMPLETE. INIT is fired when the content is not yet fully loaded but is ready for use (and will start playing on its own).

与附加事件

loader.contentLoaderInfo.addEventListener(Event.INIT, handleReady );

和它处理

public function handleReady( initEvent:Event ):void{
        MovieClip(initEvent.currentTarget.content).stop();
}

您会发现,你可以投内容 currentTarget当前属性作为影片剪辑,甚至之前停止它已被安装到舞台上。

You'll notice that you can cast the content property of currentTarget as a MovieClip and stop it even before it has been attached to the stage.

要注意,这不是安全使用的内容是很重要的进展事件属性(或任何时间之前一个 INIT 完成事件)。你会得到一个错误的对象是没有准备好效果。

It is important to note that it is not safe to use the content property in a PROGRESS event (or any time prior to an INIT or COMPLETE event). You will get an error to the effect that the object is not ready.

这篇关于AS3停止外部SWF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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