123 posts
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Sold between 10 000 and 50 000 dollars
  • United States
egobuilders says

I need a way to tell if an mp3 fails to load in Actionscript 2. Knowing if it loads successfully is easy, but I need to know when it FAILS to load. Please help! :)

mySound = new Sound();

mySound.loadSound(“song1.mp3”, true);

215 posts
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
  • United Kingdom
Ziyad says

mySound.onLoad = function(success:Boolean) {

if (success) {

// Sound Loaded

} else {

// Sound not Loaded (Failed to Load)

}

};

123 posts
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Sold between 10 000 and 50 000 dollars
  • United States
egobuilders says

I tried that already, but it doesn’t tell me if the song FAILS to load, because essentially what it’s saying is, “when then song has loaded, tell me whether or not it has loaded” due to the “onLoad” statement. It will not indicate if it failed to load, it only indicates that it has loaded. Thank you though!

215 posts
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
  • United Kingdom
Ziyad says

Well it works for me..

http://www.pastie.org/382940

Using a URL to a non existent mp3 file

123 posts
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Sold between 10 000 and 50 000 dollars
  • United States
egobuilders says

That’s weird, I used the same exact code, verbatim, but it won’t return anything when it fails. I used trace( “Failed” ) under “else”, but it didn’t trace it.

I should elaborate. I want it to tell me it failed when it tries to load an mp3 that does not exist.

mySound = new Sound() ;

mySound.loadSound(song + ”.mp3”, true) ;

mySound.onLoad = function(success:Boolean) {

if(success) {
trace("Loaded" ) ;
} else {
trace("Failed" ) ;
}

}

215 posts
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
  • United Kingdom
Ziyad says

Ah I see the problem. I don’t think it works locally with AS2 sadly.

I tried test.mp3 and it didn’t return ‘failed’ but with http://www.randomsitename.com/test.mp3 it did return ‘failed’

Hope this helps

123 posts
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Sold between 10 000 and 50 000 dollars
  • United States
egobuilders says

Cool… thanks for your help! I’ll see what I can sort out with it.

by
by
by
by
by
by