+ -
当前位置:首页 → 问答吧 → Sound加载音乐的问题

Sound加载音乐的问题

时间:2011-06-22

来源:互联网

我用sound加载了一个外部的mp3 在本地测试没有问题。上传到网络以后播放的话总有个异常

ArgumentError: Error #2068: 声音无效。
       at flash.media::Sound/play()
       at main_fla::MainTimeline/IsGotoAndPlay()


舞台上总共有三个场景  我将Sound设这成了static 方便三个场景都能引用,不知问题出在哪里。各位帮忙解决下,目前不知道问题出在哪里
复制内容到剪贴板
代码:
stop();
var loaded:Number;
var percent:Number;
var l1:Boolean = false;
var l2:Boolean = false;
var p1:Number = 0;
var p2:Number = 0;
this.addEventListener(Event.ENTER_FRAME,IsGotoAndPlay);
loading.addEventListener( Event.ENTER_FRAME, load_progress );
GlobalSound.sound_ = new Sound(new URLRequest("yinyue.mp3"));
GlobalSound.sound_.addEventListener(ProgressEvent.PROGRESS,loadingMusic);
GlobalSound.sound_.addEventListener(Event.COMPLETE,loadingMusicC);
function loadingMusic(e:Event){    
    p2 = Math.floor(GlobalSound.sound_.bytesLoaded*100/GlobalSound.sound_.bytesTotal);
    this.txt_m.text = p2+"%";
    }
function loadingMusicC(e:Event){    l2 = true;}
function IsGotoAndPlay(e:Event){
    if(l1&&l2){            this.removeEventListener(Event.ENTER_FRAME,IsGotoAndPlay);
        this.loading.txt_load.text = "100%";
        this.loading.mask_bar.y = 0;
        GlobalSound.channel = GlobalSound.sound_.play();
        //play();
    }
    else{
        this.loading.txt_load.text = Math.floor((p1+p2)/2)+"%";            this.loading.mask_bar.y = 60*(1-(p1+p2)/200);
    }
}
function load_progress(e:Event):void
{
    loaded = stage.loaderInfo.bytesLoaded / stage.loaderInfo.bytesTotal;
    percent = Math.floor(loaded * 100);
    
    p1 = percent;
    this.txt_m2.text = p1 + "%";
    if( percent == 100 )
    {
        this.txt_m2.text = "影片完成!";
        this.loading.removeEventListener( Event.ENTER_FRAME, load_progress );
        l1=true;
        //play();
    }
}

作者: sdmajun   发布时间: 2011-06-22

无文件无真像,到处发帖子,不如发文件。

作者: flash023   发布时间: 2011-06-22