【问题标题】:Flash sound actionscript start Music and stop automatically background soundFlash 声音动作脚本启动音乐并自动停止背景声音
【发布时间】:2012-11-07 18:50:58
【问题描述】:

我正在研究闪存。我想在单击 MUSIC ON 按钮时自动停止背景声音,并在单击 MUSIC OFF 时启动(自动背景声音)。

请尽快给我解决方案。

【问题讨论】:

    标签: flash actionscript


    【解决方案1】:
    var mySound:Sound = new Sound();
    var myChannel:SoundChannel = new SoundChannel();
    
    music_on_btn.addEventListener(MouseEvent.CLICK, onClickStart);
    music_off_btn.addEventListener(MouseEvent.CLICK, onClickStop);
    
    
    function onClickStart(e:MouseEvent):void
    {
    mySound.load(new URLRequest("myFavSong.mp3"));
    myChannel = mySound.play();
    }
    
    function onClickStop(e:MouseEvent):void
    {
    myChannel.stop();
    }
    

    如需更多查询,您还可以浏览这些链接, http://www.republicofcode.com/tutorials/flash/as3sound/ http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html

    希望对你有帮助...

    【讨论】:

      【解决方案2】:
      var mySound:Sound = new Sound();
      var myChannel:SoundChannel = new SoundChannel();
      var lastPosition:Number = 0;
      mySound.load(new URLRequest("mysong.mp3"));
      myChannel = mySound.play();
      
      pause_btn.addEventListener(MouseEvent.CLICK, onClickPause);
      
      function onClickPause(e:MouseEvent):void{
      lastPosition = myChannel.position;
      myChannel.stop();
      }
      
      play_btn.addEventListener(MouseEvent.CLICK, onClickPlay);
      
      function onClickPlay(e:MouseEvent):void{
      myChannel = mySound.play(lastPosition);
      }
      

      【讨论】:

        猜你喜欢
        • 2016-12-06
        • 1970-01-01
        • 2013-01-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-21
        相关资源
        最近更新 更多