我有一些AS3 MP3代碼,我的老師給我一段時間,當我在我的電腦上本地加載網站時,但我上傳了網站到我的服務器和MP3根本不加載,但網站的其餘部分是好的。由於我對AS3並不擅長,也不安靜地理解所發生的一切,所以我只是想整個發佈MP3代碼,以防萬一你們發現它爲什麼不能加載在線。順便說一下,我只從bluehost.com購買了基本的服務器空間。我沒有購買媒體服務器(我真的不知道它做了什麼)。這可能是問題嗎?AS3 MP3播放器在本地打開時載入,但在我的服務器上根本沒有顯示
var songList:Array = new Array("InBackRoom.mp3", "NoMeansYes.mp3");
var isPlaying:Boolean = false;
var currentSong:Number = 0;
var song:Sound;
var channel:SoundChannel = new SoundChannel();
var xform:SoundTransform = new SoundTransform();
seekKnob.buttonMode = true;
seekKnob.addEventListener(MouseEvent.MOUSE_DOWN, seekStartDrag);
btnPrev.addEventListener(MouseEvent.CLICK, prevHandler);
btnPause.addEventListener(MouseEvent.CLICK, pauseHandler);
btnPlay.addEventListener(MouseEvent.CLICK, playHandler);
btnNext.addEventListener(MouseEvent.CLICK, nextHandler);
volumeKnob.buttonMode = true;
volumeKnob.addEventListener(MouseEvent.MOUSE_DOWN, volumeStartDrag);
function prevHandler(evt:MouseEvent):void {
prevSong();
}
function pauseHandler(evt:MouseEvent):void {
pauseSong();
}
function playHandler(evt:MouseEvent):void {
playSong(channel.position);
}
function nextHandler(evt:MouseEvent):void {
nextSong();
}
function id3Handler(evt:Event):void {
songInfo.text = /*song.id3.artist + ": " +*/ song.id3.songName;
}
function soundCompleteHandler(evt:Event):void {
pauseSong();
nextSong();
}
loadSong(songList[currentSong]);
function loadSong(thisSong:String):void {
song = new Sound();
song.load(new URLRequest(thisSong));
song.addEventListener(Event.ID3, id3Handler);
/*playSong(0);*/
}
function playSong(position:Number):void {
if (!isPlaying) {
isPlaying = true;
channel = song.play(position);
channel.soundTransform = xform;
channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
seekKnob.addEventListener(Event.ENTER_FRAME, seekKnobUpdate);
}
}
function pauseSong():void {
seekKnob.removeEventListener(Event.ENTER_FRAME, seekKnobUpdate);
channel.stop();
isPlaying = false;
}
function prevSong():void {
if (currentSong > 0) {
currentSong--;
pauseSong();
loadSong(songList[currentSong]);
}
}
function nextSong():void {
if (currentSong < songList.length - 1) {
currentSong++;
pauseSong();
loadSong(songList[currentSong]);
}
}
function seekStartDrag(evt:MouseEvent):void {
pauseSong();
seekKnob.startDrag(true, new Rectangle(seekSlider.x, seekSlider.y + seekSlider.height/2, seekSlider.width, 0));
stage.addEventListener(MouseEvent.MOUSE_UP, seekStopDrag);
}
function seekStopDrag(evt:MouseEvent):void {
seekKnob.stopDrag();
playSong(song.length * (seekKnob.x - seekSlider.x)/seekSlider.width);
stage.removeEventListener(MouseEvent.MOUSE_UP, seekStopDrag);
}
function seekKnobUpdate(evt:Event):void {
var pos:Number = seekSlider.width * channel.position/song.length;
if (!isNaN(pos)) {
seekKnob.x = seekSlider.x + pos;
} else {
seekKnob.x = seekSlider.x;
}
}
function volumeStartDrag(evt:MouseEvent):void {
volumeKnob.startDrag(true, new Rectangle(volumeSlider.x, volumeSlider.y + volumeSlider.height/2, volumeSlider.width, 0));
volumeKnob.addEventListener(MouseEvent.MOUSE_MOVE, volumeUpdate);
stage.addEventListener(MouseEvent.MOUSE_UP, volumeStopDrag);
}
function volumeStopDrag(evt:MouseEvent):void {
volumeKnob.removeEventListener(MouseEvent.MOUSE_MOVE, volumeUpdate);
volumeKnob.stopDrag();
stage.removeEventListener(MouseEvent.MOUSE_UP, volumeStopDrag);
}
function volumeUpdate(evt:MouseEvent):void {
xform.volume = (volumeKnob.x - volumeSlider.x)/volumeSlider.width;
channel.soundTransform = xform;
}
我檢查了一切,並上傳了相同的,正確的文件結構,它應該是。
你有沒有得到任何錯誤?如果您使用Flash Player的調試版本(adobe.com/support/flashplayer/downloads.html),您應該會看到錯誤。我想象一個IOError或SecuritySandbox錯誤。 – 2010-09-13 12:31:24