views:

330

answers:

1

Hi there,

I am trying to get a flash application to stop downloading any MP3 when the user leaves the page. So far, I have been using the stop(); command on the channel, however, you can see in the browser activity that the MP3 is still downloading. On the positive, the sound has stopped.

Any ideas? I have tried the close(); command but I just get #2029 error.

Thanks in advance.

Kindest Regards

Tom

+1  A: 

As it happens, I've just found the answer.

Basically, the #2029 error is related to the MP3 stream. When the MP3 stream has finished downloading, it no longer exists, therefore can not be closed.

I fixed this by using the following function to close & stop my sound playing/streaming:

function stopMusic():void
{    
    if (my_sound.bytesLoaded < my_sound.bytesTotal)
    {
     my_sound.close();
    }

    if (my_channel) 
    {
     my_channel.stop();
    }
}

As you can see from the function, it only uses the close() command if the MP3 is still streaming. If the MP3 is loaded, it simply stops the channel.

Hope this helps someone in the future!

Tom

Tisch