Actionscript Knowledgebase: Looping Music (AS3)
Actionscript for looping music in Flash games. Requires an mp3 in the symbol library with the class name "music".
First line of code goes in Frame 1, to be run once only.
var isMusic:Boolean = false;
Remaining code goes on the title screen frame of the project/game:
var sound_music:Sound = new music();
if (!isMusic){
isMusic = true;
var sXc:SoundChannel = sound_music.play(0,999); // repeat sound 999 times
var sXt:SoundTransform = sXc.soundTransform
sXt.volume = .8;
sXc.soundTransform = sXt;
} |