actionscript 3 - Get response status code from flash Sound object -


i have music player downloads , plays music (it should play while downloading), code looks this:

sound = new sound(new urlrequest(url_stream)); 

sometimes server returns 404 (not found) , 429 (too many requests) status codes instead of music file, i'm looking way find out response status code in case of playback error, ideas?

to response status, can use httpstatusevent event urlloader :

var sound:sound var request:urlrequest = new urlrequest('http://www.example.com/file.mp3') var loader:urlloader = new urlloader()     loader.addeventlistener(         httpstatusevent.http_status,          function(event):void {             trace('http status: ' + event.status)             if(event.status == 200){                 sound = new sound(request)                 sound.play()             }         }     )     loader.addeventlistener(ioerrorevent.io_error, function(){})     loader.load(request) 

this code working 100%.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -