Using the Rectangle tool, draw a small rectangle on the stage, about 30 pixels high 10 pixel wide.
Select the Select tool and double-click the shape on the stage.
Press F8 to open the Convert to Symbol dialog box.
Select the button type, enter volume as the symbol name, and click OK.
Select the button symbol on the stage and enter the instance name handle_btn in the property inspector.
Select the button and choose Modify > Convert to symbol.
Be careful when choosing movie clip behavior. This creates a movie clip with a button in the first frame.
Select the movie clip, and then enter VOLUME_MC as the instance name in the property inspector.
Select Frame 1th on the main timeline and choose Window > action.
Enter the following code in the Actions panel:
The code is as follows |
Copy Code |
This.createtextfi Eld ("Volume_txt", 10, 30, 30, 200, 20); Volume_mc.top = volume_mc._y; Volume_mc.bottom = volume_mc._y; Volume_mc.left = volume_mc._x; Volume_mc.right = volume_mc._x + 100; volume_mc._x = +; Volume_mc.handle_btn.onPress = function () { StartDrag (This._parent, False, This._ Parent.left, This._parent.top, This._parent.right, This._parent.bottom); }; Volume_mc.handle_btn.onRelease = function () { stopdrag (); var level: Number = Math.ceil (this._parent._x-this._parent.left); This._parent._parent.song_sound.setvolume (level); this._parent._parent.volume_txt.text = level; }; Volume_mc.handle_btn.onReleaseOutside = slider_mc.handle_btn.onRelease; |
The StartDrag () parameter left, top, right, and bottom are variables that are set in the movie clip action.
Select Control > Test movie to use the volume slider.