As Create slider volume control implementation code

Source: Internet
Author: User
Tags button type

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.