Featured Site
» Posted in the Flash Kit Links section
» Title: Atlantis Media Ltd
» Comments: Greg Rudman new media creative & website design - Atlantis Media Ltd
BBM.net is designed to save you time and deliver the highest quality royalty-free music for your multimedia projects. Features include: over 450 Music Loop Packages from some of the best composers in the business, our music search engine to speed your selection process, alternate music versions & bonus sounds to use for rollovers or transitions, free technical support and free consulting.
7.
You, most probably, already have the sound AS on this frame if you have done the first tutorial. So your complete script on this frame will look something like this:
// declare a global variable
var s = 1;
// initiate sound
music = new Sound();
music.attachSound("backsound");
music.start(0, 999999);
// set the volume of the sound to zero
music.setVolume(0);
// set a variable named 'vol'
vol = 0;
// set another variable named 'fade', putting a setInterval function in it
fade = setInterval(fadeIn, 100);
// set the initial fade in function
function fadeIn() {
// fade the sound in with an increment of 3 in the variable 'vol'
vol += 3;
music.setVolume(vol);
// put an if condition to restrict the increment in volume after it reaches to 100
if (vol>=100) {
clearInterval(fade);
// create the 'step' variable
step = 1;
// create the 'fade' variable
Fade = 0;
}
}
// create the fade in and out function
// function executed on onEnterFrame
_root.onEnterFrame = function() {
// set fade out
if (Fade == 1) {
vol = vol-step;
if (vol<0) {
vol = 0;
}
music.setVolume(vol);
// set fade in
} else {
vol = vol+step;
if (vol>100) {
vol = 100;
}
music.setVolume(vol);
}
};
The global variable will help the play head move appropriately.
8.
Keeping in mind that the value of the global variable 's' is 1, select the movieclip on the stage and double click it... you will be in what is called an "edit in place space". Select the invisible button and open the AS panel. Like I said before that I assume that you have already done the previous tutorial so these actions should be there already:
on (release) {
// set the function for variable value toggle
(_root.fade=!_root.fade) ? 0 : 1;
}
Now you need to put an if condition in there. The if condition will determine the playhead movement. The complete AS on this button will look something like this:
on (release) {
// set the function for variable value toggle
(_root.fade=!_root.fade) ? 0 : 1;
// put an if condition to tell the playhead to goto
// the frame from where the play button starts fading in
// as we have pressed the button to stop the sound
// we have already set the value of the variable s to 1
// thus the playhead moves to frame 2 where it starts fading
// the play button in and the stop button out
if (_root.s == 1) {
tellTarget (this) {
gotoAndPlay(2);
// now you aobviously have to set the variable's value
// to 0, so that the next time you click the button
// the playhead moves to the 46th frame where the stop
// button starts fading in
_root.s = 0;
}
} else {
// else block executes when the varianle s is equal to 0
// when you click the button for the first time it sets the
// value of this variable to 0
// so the next time you click this button
// this else block executes
tellTarget (this) {
gotoAndPlay(46);
// now set the value of the var s to 1 again so that
// the next time this button is clicked the block with
// if condition can execute
_root.s = 1;
}
}
}
The global variable 's' plays vital part in all this. By this method you can create a toggle button for anything.
This business is really hard to explain I must confess!! I have explained the action script line by line, putting comments in it and with the help of the source file you should be able to grasp it all. Still if you thing you are confused a bit or want to discuss something.... mail me. I'll be more than happy to help you out!