[英]Controlling as2 swf playback in as3
我將內置Flash 8的swf嵌入到as3項目中。 當我調用stop()或gotoAndStop(0); 在表示嵌入式SWF實例的MovieClip上,它會停止一秒鍾,然后繼續。 嘗試在mc上調用removeChild會將其從顯示器中刪除,但swf中的音頻會繼續播放。 瑞士法郎,在這種情況下必須嵌入,我不能使用加載程序。 有任何想法嗎
編碼:
[Embed (source = "t1.swf")]
private var t1:Class;
private var mc:MovieClip;
public function iphoneTest()
{
var tf:TextField = new TextField();
tf.x = 10;
tf.y = 100;
tf.width = 100;
tf.height = 50;
tf.text = "Hello worl";
mc = new t1();
var button:CustomSimpleButton = new CustomSimpleButton();
button.width = 50;
button.height = 50;
button.x = 10;
button.y = 150;
button.addEventListener(MouseEvent.CLICK, onClick);
this.addChild(mc);
this.addChild(tf);
this.addChild(button);
}
private function onClick(e:MouseEvent):void {
mc.stop();
this.removeChild(mc);
}
您是否嘗試過mc = null;
?
也因為您知道它是一個as2 swf,所以可能應該使用avm1movie
而不是MovieClip
在最壞的情況下,您可以殺死SWF中的所有聲音...
確保導入混音器類,然后終止聲音。
import flash.media.SoundMixer;
SoundMixer.stopAll();
如果您的SWF具有任何層次結構,則需要通過它進行遞歸才能停止所有影片剪輯。
private function stopAll(do:DisplayObject):void
{
var clip:MovieClip = do as MovieClip;
if (clip != null)
clip.stop();
var container:DisplayObjectContainer = do as DisplayObjectContainer;
if (container != null)
{
for (var i:int = 0; i < container.numChildren; ++i)
{
stopAll(container.getChildAt(i));
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.