How flash attaches a sound to the timeline

Source: Internet
Author: User

Choose File > Import > Import to Library to import a sound. http://www.53dream.com
Select a sound in the library, right-click (Windows) or control-click (Macintosh), and then select Link.  
Select "Export for ActionScript" and "Export in first frame", and then specify the sound identifier a_thousand_ways.
Add a button on the stage and name it play_btn.
Add a button on the stage and name it stop_btn.
Select Frame 1th on the main timeline and choose Window > action.
Add the following code to the Actions panel:

The code is as follows Copy Code

var song_sound:sound = new sound ();
Song_sound.attachsound ("A_thousand_ways");
Play_btn.onrelease = function () {
Song_sound.start ();
};
Stop_btn.onrelease = function () {
Song_sound.stop ();
};


The code first stops the speaker movie clip. It then creates a new Sound object (Song_sound) and attaches the link identifier to the object as the A_thousand_ways sound. The Onrelease event handlers associated with the PLAY_BTN and Stop_btn objects start and stop the sound by using the Sound.start () and Sound.stop () methods, and also play and stop the attached sound.

Select "Control" > "Test movie" to try listening to the sound.

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.