控制as2 swf在as3中播放

发布于 2024-09-27 01:35:15 字数 957 浏览 9 评论 0原文

我正在将 flash 8 中内置的 swf 嵌入到 as3 项目中。当我调用 stop() 或 gotoAndStop(0); 时在代表嵌入 swf 实例的 MovieClip 上,它会停止一秒钟,然后继续。尝试在 mc 上调用removeChild会将其从显示中删除,但 swf 中的音频继续播放。 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);
   }

I am embedding a swf built in flash 8 into an as3 project. When I call stop() or gotoAndStop(0); on the MovieClip that represents an instance of the embedded swf it stops for a sec and then continues. Trying to call removeChild on the mc removes it from the display but the audio in the swf keeps playing. The swf, in this case must be embedded, I cannot use loader. Any ideas

The code:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

久而酒知 2024-10-04 01:35:15

你尝试过mc = null;吗?

另外,由于您知道它是 as2 swf,因此可能应该使用 avm1movie 而不是 MovieClip

did you try mc = null;?

also since you know it's an as2 swf, should probably use avm1movie instead of MovieClip

十雾 2024-10-04 01:35:15

在最坏的情况下,您可以杀死 SWF 中的所有声音...

确保导入混音器类,然后杀死声音。

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

At very worst you can just kill all sounds in the SWF...

Make sure you import the sound mixer class then kill the sound..

import flash.media.SoundMixer; 
SoundMixer.stopAll();
浅语花开 2024-10-04 01:35:15

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

If your SWF has any hierarchy, you'll need to recurse through it to stop all movie clips.

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));
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文