Two ways to embed a flash file in an audio file

Source: Internet
Author: User
Tags sin

Core Tip: This article describes two ways to embed an audio file in a flash document so that it can play correctly in Flash Player.

This article describes two ways to embed an audio file in a flash document so that it can play correctly in Flash Player.

1, the establishment Sound object uses the load () method to load the external MP3 to play;

2. Let the Sound object monitor the Sampledata event so that the sound generated dynamically by the program can be played, for example:

The following example plays a simple sine wave.

The following is a reference fragment:

var mysound:sound = new Sound ();

function Sinewavegenerator (event:sampledataevent): void {

for (var c:int=0; c<8192; C + +) {

Event.data.writeFloat (Math.sin (c+event.position)/MATH.PI/2) *0.25);

Event.data.writeFloat (Math.sin (c+event.position)/MATH.PI/2) *0.25);

}

}

Mysound.addeventlistener (Event.sample_data,sinewavegenerator);

Mysound.play ();

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.