hope this helpsPHP Code:/*
import your mp3 to the Library, give it a Linkage Identifier - myMP3
add a button to the stage - give it an instance name - fadeBtn
add this code to the main timeline, (same frame as the button)
*/
this.createEmptyMovieClip("clip",1000);
mySound = new Sound(clip);
mySound.attachSound("myMP3");
this.createEmptyMovieClip("FADEin",2000);
this.createEmptyMovieClip("FADEout",3000);
vol = 0;
inc = 0.5;
inc2 = 1;
songPlay = false;
function fadeIn(){
FADEout.onEnterFrame = null;
mySound.setVolume(0);
if(!songPlay) {
mySound.start();
songPlay = true;
}
FADEin.onEnterFrame = function(){
trace("fade in volume - "+vol)
vol>100 ? vol=100 : vol+=inc;
vol==100 ? FADEin.onEnterFrame = null : null;
mySound.setVolume(vol)
}
};
function fadeOut(){
FADEin.onEnterFrame = null;
FADEout.onEnterFrame = function(){
trace("fade out volume - "+vol)
vol<0 ? vol=0 : vol-=inc2;
mySound.setVolume(vol);
if(vol==0){
FADEout.onEnterFrame = null;
mySound.stop();
songPlay = false;
}
}
};
fadeBtn.onRollOver = function(){
fadeIn();
};
fadeBtn.onRollOut = function(){
fadeOut();
};
![]()




Reply With Quote