Skip to main content
Inspiring
October 29, 2015
Question

How to prevent Sound.load slow down FPS?

  • October 29, 2015
  • 1 reply
  • 501 views

Hi!

I have a mp3 player app write by AS3 with main swf load embedded swf that load external sound and playback it with some animations. I've set my app FPS by 60. Everything work well in local (with flash debugger), but problem appear when I host my app on php server. In the first time sound load, FPS slow down (about 20) while sound loading or even sound fully loaded. So, it make animations is very slow. But, when run my app in the next times (refresh browser), it work well because (I think) sound are cached. I try to clear browser cache and run my app, the problem appear again.

How can I fix that? Thank for advance!

This topic has been closed for replies.

1 reply

kglad
Community Expert
October 29, 2015

preload your sound or display a simple non-cpu taxing animation while the sound is loading.

Inspiring
October 30, 2015

kglad a écrit:

preload your sound or display a simple non-cpu taxing animation while the sound is loading.

Sorry, I don't quite understand. Can you clarify?

Inspiring
October 31, 2015

Add a complete event listener to your sound and play it on load complete, (preload your sound).

var my_sound:Sound = new Sound();

my_sound.addEventListener(Event.COMPLETE, onSoundLoaded);

my_sound.addEventListener(IOErrorEvent.IO_ERROR, onSoundLoadError);

my_sound.load(new URLRequest("sound.mp3"));

function onSoundLoaded(e:Event):void

{

   my_sound.play();

}

function onSoundLoadError(e:IOErrorEvent):void

{

   trace(e.text);

}