Vous êtes sur la page 1sur 5

Flash Tutorial 8 APIIT

FLASH TUTORIAL 8
(Working with sound)

Part 8a: Adding Sound into Flash MX

1. We can add *.wavs, *.mp3s and any other audio format you want to a flash
animation.
2. Before we can use sounds, we have to import it into our project library. From the
file menu, click on IMPORT then IMPORT TO LIBRARY. Find the file or
files you want imported and click ok.

3. The library view is not viewable by default so you will probably have to hit ctrl+L
or select Windows>Library. When it opens, it will appear in the bottom right
hand corner of your workspace. If you click on the filename to highlight it, it will
show you the cool wavelength above it.

INTRO TO MULTIMEDIA APPLICATIONS (CE00291-1) 1


Flash Tutorial 8 APIIT

4. To include the audio, you have to select a single frame or keyframe in one of your
layers.
5. Now highlight the audio file name in your library, and drag the file from the
library to stage. You would now see that wave appeared in the frames in timeline.
6. Highlight the wave in any part of the frames, your properties tab (by default is
located on the bottom of your workspace) will display the options. You may want
to experiment a little bit to see what everything does. In short, under Sync: there
are four choices. EVENT will play the entire audio clip in its entirety regardless
of how long the animation or intro is. If you select STREAM, the audio will
begin at the beginning of the clip and end the minute the last frame of your
animation is over. Selecting STOP or START will make it ignore the action script
“start” or “end” commands.
7. From this menu, you can select how many times you want the sound to repeat or
you can have it continually loop until the end of time.

8. Now press (Ctrl+Enter) to view your animation.

Part 8b: Creating Dynamic Sound

* Run " T8-soundOnOff.swf" to have a preview of what can be accomplished from this tutorial.

Part 1(a): Creating Background Sound

1. Open the file named “T8-bkgdSound.fla” file.

2. Open the Library (Ctrl+L).

3. On the main stage, insert a new layer named “sound”.

4. Choose File>Import>Import to Library.

5. Import “T8-Hype.mp3” file.

6. With the 1st frame in the sound layer selected, drag the “T8-Hype.mp3” sound out
of the Library and drop it anywhere on the Stage.

7. Play the movie (Ctrl + Enter)

INTRO TO MULTIMEDIA APPLICATIONS (CE00291-1) 2


Flash Tutorial 8 APIIT

Part 1(b): Creating Sound on Sound Off buttons

1. Return to main stage, point to the sound layer, then view the Properties Inspector,
make sure “Sync” is set to Start, choose Repeat, and type 5.

2. Create a new layer and name this layer as “buttons”. Drag two buttons named
“soundOn” and “soundOff” from the library and put anywhere on the stage.

3. Select sound on button, press F9 and type the following script:

on (release) {
gotoAndPlay(1);
}
4. Select sound off button, press F9 and type the following script:

on (release) {

stopAllSounds();

5. In the timeline, add a new layer and name it as actions. Make sure the actions
layer is above all layers.

6. Select all the layers at once and press F5 to add a frame to each layer in the
Timeline.

7. In the timeline, select frame 2 of the actions layer and press F7 to add a blank
keyframe. Press F9 and type the following scripts:

Stop();

INTRO TO MULTIMEDIA APPLICATIONS (CE00291-1) 3


Flash Tutorial 8 APIIT

8. Play the movie (Ctrl + Enter).

Part 2: Script for Producing External Sound

You may also set sound button to play external sound file, do as follows:

1. You can use “audacity” open source audio software to edit external sound file.

2. File – import – choose “T8-alert.wav”

3. Press Ctrl + L to display Library

4. In the library, point the “T8-alert.wav”, then right click, choose “Linkage”

5. Check “Export for ActionScript”

6. Type “beep” in the “Identifier” text field and then click OK.

INTRO TO MULTIMEDIA APPLICATIONS (CE00291-1) 4


Flash Tutorial 8 APIIT

8. Create a button, point to the button, press F9 and type the following script:

On(press){
mySound=new Sound();
mySound.attachSound(“beep”);
mySound.setVolume(100);
mySound.start();
}

9. Ctrl + Enter to play the movie

THE END

INTRO TO MULTIMEDIA APPLICATIONS (CE00291-1) 5

Vous aimerez peut-être aussi