Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //VERSION: V2.0 EXTENDED WITH LOOP BOOLEAN
- //FREE TO USE! NO NEED TO GIVE CREDIT!
- //SOUND AND MUSIC
- SFX = true;
- sss_loopSound;
- MUSIC = true;
- firstMusic = 0;
- this.createEmptyMovieClip("m0",100);
- mm0 = new Sound(m0);
- mm0.attachSound("bg0");
- mm0.onSoundComplete = function() {
- mm0.start();
- };
- //PLAY ANY SOUND ONCE OR LOOP!
- function playSound(id:String, vol:Number, loopVersion:Boolean) {
- if (SFX) {
- if (!loopVersion) {
- this.createEmptyMovieClip("sss" + soundNum,10500 + soundNum);
- var __reg2 = new Sound(this["sss" + soundNum]);
- __reg2.attachSound(id);
- __reg2.setVolume(vol);
- __reg2.start();
- soundNum >= 30 ? (soundNum = 0) : soundNum++;
- } else {
- if (!sss_loopVersion) {
- this.createEmptyMovieClip("sss_loopVersion",10531);
- sss_loopSound = new Sound(this["sss_loopVersion"]);
- sss_loopSound.attachSound(id);
- sss_loopSound.setVolume(vol);
- sss_loopSound.start();
- }
- sss_loopSound.onSoundComplete = function() {
- sss_loopSound.start();
- };
- }
- }
- }
- //USAGE FOR LOOP:
- if (...condition) {
- playSound("mySound",100,true);
- //Linkage Name, Volume, is it for loop or not.
- } else {
- if(sss_loopVersion){
- sss_loopSound.stop();
- sss_loopVersion.removeMovieClip();
- }
- }
- }
- //onEnterFrame function: place this into your onEnterFrame = function(){}
- firstMusic == 0 ? (mm0.start(), firstMusic=1) : null;
- MUSIC ? mm0.setVolume(40) : mm0.setVolume(0);
- //if the music boolean is true then set the music's volume to 40 else set it to 0!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement