在as3中控制as2 swf播放

时间:2010-10-08 20:38:05

标签: actionscript-3 flash movieclip actionscript-2 playback

我将内置在flash 8中的swf嵌入到as3项目中。当我调用stop()或gotoAndStop(0)时;在代表嵌入式swf实例的MovieClip上,它停止一秒然后继续。尝试在mc上调用removeChild会将其从显示中删除,但swf中的音频会继续播放。 swf,在这种情况下必须嵌入,我不能使用loader。任何想法

代码:

    [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);
   }

3 个答案:

答案 0 :(得分:0)

你试过mc = null;吗?

因为你知道它是as2 swf,所以应该使用avm1movie代替MovieClip

答案 1 :(得分:0)

最糟糕的是你可以杀掉SWF中的所有声音......

确保导入混音器类然后终止声音..

import flash.media.SoundMixer; 
SoundMixer.stopAll();

答案 2 :(得分:0)

如果你的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));
        }
    }
}