Control Playing of Audio

Control Playing of Audio

Flash CS4 Tutorial

 

How to Set Audio Streams, Starts and Stops on Flash Timeline

 

 

Whenever audio is placed on the timeline, it is assigned a default mode called Event. In other words, you can place your audio at frame 20 of your timeline. If the animation loops back around to frame twenty and your audio is still playing, then you will hear two versions of the same audio at the same time.

A solution to this problem is to set your audio to one of four states; Stream, Event, Stop or Start.

In this tutorial we will import audio into the Library and add it to the timeline. The audio is selected in the timeline and the mode is set in the Properties panel.

 

Step One

In a new flash document, add a new layer. Name the upper layer Actions and the lower layer Audio.

Step Two

Choose File > Import > Import to Library.

Step Three

Navigate to your mp3 or aif file and choose Import.

Step Four

Open the Library (Window > Library).

Step Five

Select frame one of your Audio layer and drag the audio file in the Library to the stage.

Step Six

Publish your movie by pressing Cmd/Return (PC - Ctrl/Enter). The audio starts playing and plays only once.

Step Seven

Click frame one of the Audio layer and open the Properties panel.

Step Eight

In the Sound section, with the lower box set to Repeat, change the value to 2. Now the audio will play two times, then stops.

Step Nine

Extend the content of your Audio layer by clicking frame 20, then press F5.

Step Ten

Click frame 20 of your Actions layer and press F6 to add a keyframe.

Step Eleven

Option double-click (PC - Alt double-click) frame 20 of the Actions layer to open the Actions panel.

Step Twelve

Copy/Paste the following code to the ActionScript panel.

stop();

Step Thirteen

Select the audio waveform of the Audio layer and open the Properties panel.

Step Fourteen

In the Sync box there are four settings, Event, Start, Stop and Stream.

Step Fifteen

By setting Sync to Event, the audio plays from start to finish without stopping. If your animation repeats back to the start of the audio before it is finished, two versions of the audio play at the same time. In other words, if you remove the stop() command in the Actions panel, the audio will repeat over itself.

Step Sixteen

When you set Sync to Start, the audio plays from start to finish without stopping. If your animation repeats back to the start of the audio before it is finished, only one version of the audio will play.

Step Seventeen

Set Sync to Stop and the audio stops at at that keyframe. This is a good way to stop your audio once it reaches a specific frame. For instance, you may have a keyframe at frame one with Sync set to Start. To stop your audio, add another keyframe at frame 20 with Sync set to Stop.

Step Eighteen

By setting Sync to Stream, the audio plays until you stop the timeline (in this example, frame 20).

AIF or MP3

Using this method you can import either .aif files (Mac) or mp3 files (Mac or PC).

Audio Settings

Prior to importing audio, it is best to verify the project audio settings. To view and change the default audio settings, choose File > Publish Settings. Click the Flash tab, then click the Set.. button next to Audio Stream.

Additional Audio Import Information

For additional audio import instructions, see topic, Importing Audio.

Removing Audio from Timeline

To remove audio from the timeline, select the audio and open the Properties panel. In the Sound section, choose Name > None.

 

Stock Images