123 posts
  • Has been part of the Envato Community for over 6 years
  • Has sold $10,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
  • Has been part of the Envato Community for over 7 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Sells items exclusively on Envato Market
+1 more
Ziyad says

mySound.onLoad = function(success:Boolean) {

if (success) {

// Sound Loaded

} else {

// Sound not Loaded (Failed to Load)

}

};

123 posts
  • Has been part of the Envato Community for over 6 years
  • Has sold $10,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
  • Has been part of the Envato Community for over 7 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Sells items exclusively on Envato Market
+1 more
Ziyad says

Well it works for me..

http://www.pastie.org/382940

Using a URL to a non existent mp3 file

123 posts
  • Has been part of the Envato Community for over 6 years
  • Has sold $10,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
  • Has been part of the Envato Community for over 7 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
  • Has been part of the Envato Community for over 6 years
  • Has sold $10,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
egobuilders says

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

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by