AS3.0 plays sound without delay

I have several classes.

My document class (Main.as) instantiates the class and Soundsloader. In the game class, when a player picks up an item in a game, I want to play a short sound. I am doing this with the following code:MovieClip(this.main_object.sound_loader).playPickUp();

In my document class, I also create an instance of SoundsLoader, which basically should load all sounds. (only one in my example below)

package  {
    import flash.display.MovieClip;

    public class SoundsLoader extends MovieClip{

        private var pick_up_item:sound_pickup_item =  new sound_pickup_item;

        public function SoundsLoader() {
        }

        public function playPickUp(){
            pick_up_item.play();
        }
    }
} 

However, when I use the methods, my swf file freezes momentarily, plays a sound, and then continues. So what's the best way to do this? (I use .wav sound)

+3
source share
1 answer

, , , - . , , , preloader - .

, , , .

:

public function SoundsLoader() {            
    var songController:SoundChannel = pick_up_item.play();          
    var volControl:SoundTransform = songController.soundTransform;
    volControl.volume = 0;
    songController.soundTransform = volControl;
}

public function SoundsLoader() {            
    var songController:SoundChannel = pick_up_item.play();          
    songController.stop;
}
+3

All Articles