闪吧论坛's Archiver

dhf481229 发表于 2008-6-22 01:09

求救,关于加载mp3的问题

//加载声音
mysound.addEventListener(MouseEvent.MOUSE_DOWN,sound_down)
function sound_down(e:MouseEvent):void{
    var _sound:Sound=new Sound();
  _sound.load(new URLRequest("song.mp3"));
  _sound.addEventListener(Event.COMPLETE, completeHandler);
}
function completeHandler(e:Event):void{
  e.target.play();  
    }
    在这我加载了一首mp3,但我想实现的是当我再次点击mysound这个按钮时能再重新加载、播放当前声音,也就是想实现当再次点击mysound时能卸载当前声音

终极讨厌 发表于 2008-6-22 07:34

mysound.addEventListener(MouseEvent.MOUSE_DOWN,sound_down);
var p_channel:SoundChannel =new SoundChannel;
var p:Boolean =true;
function sound_down(e:MouseEvent):void {
        var _sound:Sound=new Sound();
        _sound.load(new URLRequest("song.mp3"));
        _sound.addEventListener(Event.COMPLETE, completeHandler);
}
function completeHandler(e:Event):void {
        p_chanle.stop;
        if (p) {
                var _sound:Sound =e.target as Sound;
                p_channel=_sound.play();
                p=false;
                return;
        }
        p=true;
}

beijing1995xz 发表于 2008-6-28 17:12

偶会!!!:b36

页: [1]

Powered by Discuz! Archiver 7.0.0  © 2001-2009 Comsenz Inc.