Link to home
Create AccountLog in
Avatar of hzrdc2
hzrdc2

asked on

Play new sound in every frame

I have the following code that plays an mp3 on the first frame. When complete, it goes to the second frame.

Is it valid to put similar code in my the second frame of the my actions layer? (just adjust var names and such).

It works, I just want to know if its in best practice.
var soundReq:URLRequest = new URLRequest("path1_a.mp3");
var sound:Sound = new Sound();
sound.load(soundReq);
 
sound.addEventListener(Event.COMPLETE, onComplete);
sound.addEventListener(Event.SOUND_COMPLETE, soundFinished);
 
function onComplete (event:Event):void {
        sound.play();
}
 
function soundFinished (event:Event):void {
        gotoAndStop(2);
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of blue-genie
blue-genie
Flag of South Africa image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer