views:

24

answers:

1

sup everyone, I'm in my last quarter in college making my online portfolio and I just wanted to say that you guys have been a load of help the last week. Almost more so than my teachers...

So I have some AS3 MP3 code that my teacher gave me a while ago and it loads perfectly when I load the site locally on my computer, but I uploaded the site(to my server) and the MP3 doesn't load at all, but the rest of the site is fine. Since im not great at AS3 and don't quiet understand everything that is going on im just going to post the MP3 code in its entirety just incase any of you can spot why it won't load online....(by the way I only bought the basic server space from bluehost.com...I did not purchase a media server(which I really don't know what it does), could this be the problem?)

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

While writing this I thought I figured out the problem, that I forgot to upload the MP3's but I checked and everything is uploaded and in the same, correct file structure that it should be.

A: 

It's not necessary to use a media server. Use a web debugger such as Firebug to see if the requests for the MP3 files are being made, to where they are being made and if the response is appropriate. It might be something as simple as case sensitivity in the url.

spender
I don't think it could be that since I used fireFTP to upload everything...Meaning I just clicked and dragged everything from the file that works on my computer to the file space I have online...Im going to go through and check everything but im relatively sure that if any url's or case sensitivity was off originally, it wouldn't have worked on my computer, locally.
mike
Have you tried Firebug yet?
spender
I ues firebug, but I didnt know you could use it w/ flash?!
mike
In the browser, all requests are made via the browser. Flash is no exception to this, and makes all requests via the browser. Therefore you can use Firebug to monitor the requests that Flash makes and the corresponding responses.
spender