Home Tutorials Forums Articles Blogs Movies Library Employment Press

<< Prev 5 | Next 5

soft fade flip

/*
You must have a Folder named _mp3_
and an mp3 file inside named _atmo.mp3_
Use a Button _FadeFlip_ to call this script

Please leave the following Line intact:
soft fade flip coded by jochen preusche - www.jochenpreusche.de*/
i = 0;
c = 100;     // change in
d = 300;     // duration of change process. Framerate related

atmo = new Sound();
atmo.loadSound("mp3/atmo.mp3", true);
atmo.onLoad = function() {
        atmo.setVolume(0);
        atmo.start();
};


cm = c;
cmc = c;
fadeValue = c;
inOut = "out";

FadeFlip.onRelease = function() {
        i = i+(d-(2*(i%d)));
        cm = cm*(-1);
        if (cm != c) {
                cmc = (0);
        }
        if (cm == c) {
                cmc = (c);
        }
        if (inOut == "in") {
                inOut = "out";
        } else {
                inOut = "in";
        }
        Fade ();
};

function Fade () {
        _root.onEnterFrame = function() {
                if (((inOut == "out") && (fadeValue>0)) || ((inOut == "in") && (fadeValueMath.cos(Math.PI*i/d)-1)+cmc;
                        atmo.setVolume(c-(fadeValue));
                        i = i+5;
                }
        }
};
Fade ();
/*End soft Fade Flip */
stop();

Posted by: Jochen Preusche | website http://www.jochenpreusche.de
Sound loops until button is pressed
Sound loops until button is pressed
Damien Mason

//on the frame//
stop();
introStatus=0
Loop01 = new Sound();
Loop01.attachSound("intro");
Loop01.start(0,1);
Loop01.onSoundComplete = function() {
if ( introStatus==0 ) {
 Loop01.start(0,1);
 } else if ( introStatus==1 ) {
 gotoAndStop("level 1");
}
}
//on the button//
on (release) {
 introStatus = 1
}

Posted by: Damien Mason | website http://www.bssc.edu.au/staff/pages/damien
Sound Player
// soundplayer code by flash.andihaas.de
var tl = this;
// timeline
var pfad = "music/";
//folder path
var trackList_arr = ["track1.mp3", "track2.mp3", "track3.mp3"];
var trackNames_arr = ["song 1", "song 2", "song 3"];
var m = new Sound(this);
function SoundPlayer(arg) {
        loop = 1;
        arg--;
        //static count vars
        tl.anzeige.text = "Playing: "+trackNames_arr[arg];
        //display
        //	trace("Playing: "+trackNames_arr[arg]);
        m.loadSound(pfad+trackList_arr[arg], true);
        m.onSoundComplete = function() {
                tl.anzeige.text = "Playing: "+trackNames_arr[arg]+" ;) "+loop+++". times";
                trace("Playing: "+trackNames_arr[arg]+" zum "+loop+++". mal");
                m.loadSound(pfad+trackList_arr[arg], true);
        };
}
//navi
for (var i = 1; i<=trackList_arr.length; i++) {
        tl["btn_"+i].id = i;
        tl["btn_"+i].onPress = function() {
                SoundPlayer(this.id);
        };
}

Posted by: Andi Haas | website http://www.andihaas.de
sound queue
Sound.prototype.queue=function()
{
        this.attachSound(arguments[0][0]);
        this.control=1;
        this.sounds=arguments[0];
        this.start();
        this.onSoundComplete=function()
        {
                if(Number(this.sounds.length) == Number(this.control))
                delete this.onSoundComplete;
                else
                {
                        this.attachSound(this.sounds[this.control++]);
                        this.start();
                }
        }
}
som=new Sound();
som.queue(["s1","s2","s3","s4"]);//linkages

Posted by: Victor Fernandes fogaça | website http://www.oscobras.cjb.net
Sound when a key pressed
if i wanted to make a sound called "gong" (without the quotes) play when the key G is pressed i would put in the following code.
on (keyPress "g") {
        mySound= new Sound
        mySound.attachSound("gong")
        mySound.start(0,1)
}
NOTE: i would have to make sure that the sound gong was exported with the name "gong" '(without the quotes)


Posted by: Xtraterrestrial | website http://diverse.orcon.net.nz

<< Prev 5 | Next 5

Copyright 2000-2010 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.