Home | Web Design | App / Game development | Flash | Flash Games | Graphic Illustration | Technical Illustration | Contact | Site Map    Twitter
 
  Galaxy Graphics Limited

Technical InformationActionscript 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;
}

 
Site content Copyright © 2001-2014 Galaxy Graphics Limited. | Privacy Policy | Terms of use