Tuesday, March 13, 2007

How to create ON/OFF Button in flash

in flash, everyone wants to import music in it so thier flash can be more attractive and interesting. However, sometime, the viewer doesn't want to hear the music because the sound is too lout or they are in public. In this blog, this blog will show how to create a On/Off button in a movie flash. This tutotial belongs to Jajanthi and from website www.enthosweb.com:
To start with, make 2 buttons. 1 for ON and another, for OFF

Next you need to create 2 Movie clips.

* For sound
* For buttons

Okay let's start with the Sound Movie clip

* Create three keyframes.
* Insert stop action to all the keyframes.
* Insert your music into frame1.

NOTE:Keep the loop count of your music fairly an high value and the sync should be at event.
* In frame2 insert the following code,

gotoAndStop(1)

* In frame3 insert the following code,

gotoAndPlay(1);

Now you are through with your Sound Movie clip.

Next, Lets start with the Button Movie clip

* Create 2 keyframes.
* Insert stop actions to both the keyframes.
* Insert OFF button into frame1.
* Select your OFF button and insert the following code,

on (release) {
tellTarget ("../music") {
stopAllSounds();
}
}
on (release) {
nextFrame();
}

* Insert ON button into frame2.
* Select your ON button and insert the following code,

on (release) {
tellTarget ("../music") {
nextFrame();
}
}
on (release) {
prevFrame();
}

* Insert your Sound Movie clip into your movie and name it "music" in your instance panel.
* Insert your Button Movie clip into your movie.
* Now press ctrl+enter to play your movie.
I hope after this tutorial, everyone can easily create a convenient flash not only for the viewer but also for yourself.

Ref:
Jayanthi (2004), Flash Sound On/Off Button, ewww.ntheosweb.com, viewed 14 March 2007, http://www.entheosweb.com/Flash/flash_sound_button.asp

No comments: