How to check that sound is already load?
Hi, noobs here!
question is... How to check that sound is already load? so i can just play if sound already load... far as i try is
var si:SoundInstance = SoundAS.getSound("somesound");
but at present it will throw error if it not exist, i did expected null for first load then call SoundAS.loadSound if si is null e.g.
if(!si)
SoundAS.loadSound("somesound.mp3", "somesound");
and if i load sound via SoundAS.loadSound again without check for existing SoundAS.loadCompleted is seem to be never fire for second load same url and type.
btw, i don't think it's a good idea to try catch there. "null for non exist SoundAS.getSound" should be better there.
Thanks
I have a same problem.
public function getSound(type:String, forceNew:Boolean = false):SoundInstance
if specfied type is not found, it will throw new error, and this error not catch in SoundManager.
so is should possible add catch in that "try...finally" code block ? or if not found specfied sound, do not fire a error, just trace a message?
or maybe add a new method containSound?
I changed it locally so that getSound returns null instead of throwing an error. Though a containsSound would be good.
I did the same on my side.
yes please add support for containsSound!
SoundAS.getSound('XXX').sound.addEventListener(Event.COMPLETE,COMPLETE); SoundAS.getSound('XXX').sound.addEventListener(IOErrorEvent.IO_ERROR,IO_ERROR);