-
1. Re: Sound -> 'complete' event vs. SoundChannel -> 'soundComplete' event
kglad Feb 25, 2011 5:58 PM (in response to Ziggizag)the sound class complete event is dispatched if you load a sound (eg, mp3 file) into a sound instance and that load completes.
the soundchannel's soundcomplete event is dispatched if you play a sound and that sound completes its play.
-
2. Re: Sound -> 'complete' event vs. SoundChannel -> 'soundComplete' event
somascope Feb 25, 2011 6:02 PM (in response to Ziggizag)Sound class
This doesn't actually have a complete event (in the way you might be thinking of). What you might be refering to (in the AS Docs) is usage of the flash.events.Event.COMPLETE event. This is only used for loading sound files, and tells you when the data has successfully loaded. So, typically, you'd just use the Sound class to manage the loading of things...
SoundChannel class: flash.events.Event.SOUND_COMPLETE
This is what should be used for detecting the completion of audio. The SoundChannel class is what you'd want to use to control the stopping/pausing/playing of things.
private var _s:Sound;
private var _sc:SoundChannel;
When loading audio...
_s = new Sound();
_sc = new SoundChannel();
_s.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
_s.load(new URLRequest(url));
When playing audio...
_sc = _s.play();
_sc.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
-
3. Re: Sound -> 'complete' event vs. SoundChannel -> 'soundComplete' event
Ziggizag Feb 25, 2011 6:10 PM (in response to somascope)Thank you guys !
-
4. Re: Sound -> 'complete' event vs. SoundChannel -> 'soundComplete' event
kglad Feb 25, 2011 6:13 PM (in response to Ziggizag)this may be a technicality that you don't understand but the answer you marked as correct is not correct. the sound class does have a complete event.
-
5. Re: Sound -> 'complete' event vs. SoundChannel -> 'soundComplete' event
Ziggizag Feb 25, 2011 6:29 PM (in response to kglad)Sure,
I think it was miswording - Sound class has 'compete' event but it's about loading not playing. That means loading sound data may complete prior completing sund playing...
The problem is... It seems SoundChannel's SoundComplete event does not work for me... I need to clarify why... The sound finish to play and nothing happens!
-
6. Re: Sound -> 'complete' event vs. SoundChannel -> 'soundComplete' event
Ziggizag Feb 25, 2011 6:42 PM (in response to Ziggizag)Yeap - this is because sound.play() method creates a new SoundChannel object each time it's called. One needs to attach event listener to this instance each time too.
-
7. Re: Sound -> 'complete' event vs. SoundChannel -> 'soundComplete' event
somascope Feb 25, 2011 8:57 PM (in response to kglad)Indeed, it's good of kglad to point out these things. I'd come back to edit my posting a minute after I made it, but I lsot my Internet connection. Anyways, as Ziggizag points out, it was more about the audio/sound completion that was the point of my posting. I meant to say "doesn't have a complete event in the way you are thinking it does" ;-)
Good details, guys.



