Flash Button control sound specific implementation

Source: Internet
Author: User
Button | Control just asked me how to control the start and stop of sound in Flash. At first, I want to stop and play with the button, OK? Try again to remember that the sound cannot be so controlled. If you want to know how to do it, please look down. Show:

Click here to download the source file

   First prepare your material: sound file (not too big OH), do an animation and then pull out a button from the library.
Here we go. Position the actors first. I put it like this, layer one animation, take a name is called Animation bar. Layer Two-place button. Layer three to put the sound. (In fact, the location is casual). Let's put the actors up. See figure below:

Right click on your voice inside the library, select "Link ..."

In the pop-up dialog box to do the following settings:

In coming to the main scene. At the first frame of the sound layer, open the Action panel (press F9) and write the following code in the Action window:
s = new Sound ();
S.attachsound ("Music");
S.stop ();

Click on the first frame of the animation layer and write in the action panel:
Stop (); Finally click on the button in the button's action panel to write:
On (release) {
S.start ();
Play ();
}

All right, finish it, try the effect. It's so simple. (To make a button to stop the sound, put S.start (); Change to S.stop (); it's OK. )

Note: This animation can only be made in flashMX2004 or later versions. Because this is the grammar of AS2.0. The master saw don't laugh at me oh.



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.