Reputation: 1027
package{
import flash.display.MovieClip;
public class MySoundContainer extends MovieClip {
var _mySound:MySound = new MySound(); // my custom sound imported in library
public function _OnButtonClick(e:MouseEvent) : void {
_mySound.play(); // first call shows delay in play
}
}
}
When the button is clicked first time, I see a noticeable delay in playing the sound.
Is it possible to preload the sound effect before hand for the embedded files?
Upvotes: 0
Views: 155
Reputation: 1027
Latency in playing short sounds in flash helped me immensely to understand various reasons for latency in sound play.
I found (from the above link) that the problem was happening only while previewing within flash. It works perfectly when running the compiled swf.
In case somebody runs into a issue like I did, they should try to do File->Publish and run the .html file.
Upvotes: 0
Reputation: 5267
May be calling play
and mute the sound (with volume = 0) when the app start and return volume back later in _OnButtonClick
will help you.
But it's strange, embed sounds don't need in preloading, they are already loaded with the swf file. May be it's bufferization or volume fade (increasing volume from 0 to 1 for 1-2 sec) in the beginning of mp3 file. Does this delay occur only at first click?
Upvotes: 1