Volume Slider bar in Flash

1.Create new fla file save it as volumeslider.fla

2,create 4 new layer in that file name as it actions buttion slider bar

3.select the bar & create one bar in the layer & convert into movieclip give the instance name as bar_mc

4.select the slider layer & create the slider ,convert into the movieclip give the instance name as slider_mc

5.In button layer create the play,stop buttons,give the instance name for the buttons as play_btn,stop_btn

6.Import the song into library give the identifier name as “test” & select the linkage checkbox in the properties.

7.Finaly select the action layer & paste this code for the volume

slider slider_mc.onPress = function() { this.startDrag(true,_root.bar_mc._x,_root.bar_mc._y,_root.bar_mc._x+335,_root.bar_mc._y); } in this 335 indicate as the width of thebar .

slider_mc.onRelease = slider_mc.onReleaseOutside= function() {

this.stopDrag();

}

play_btn.onRelease = function() {

mySound = new Sound();

mySound.attachSound(“test”);

mySound.start(0,50);

}

stop_btn.onRelease = function() { stopAllSounds(); }

slider_mc.onMouseMove =function() {

np = new Object();

np.x= this._x;

np.y= this._y;

_root.bar_mc.globalToLocal(np);

_root.mySound.setVolume(-1*np.x);

}

Advertisements

Posted on November 23, 2009, in Flash and tagged . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: