MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 574

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

3.
Select Export for ActionScript and Export in First Frame; then give the sound the identifier
a_thousand_ways
4.
Add a button to the Stage and name it
5.
Add a button to the Stage and name it
6.
Select Frame 1 in the main Timeline, and select Window > Actions.
Add the following code to the Actions panel:
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();
};
This code first stops the speaker movie clip. It then creates a new Sound object
(
) and attaches the sound whose linkage identifier is
song_sound
event handlers associated with the
onRelease
and stop the sound by using the
play and stop the attached sound.
7.
Select Control > Test Movie to hear the sound.
To create a sliding volume control:
1.
Using the Rectangle Tool, draw a small rectangle on the Stage, approximately 30 pixels
high by 10 pixels wide.
2.
Select the Selection Tool and double-click the shape on the Stage.
3.
Press F8 to open the Convert to Symbol dialog box.
4.
Select the Button type, enter a symbol name of volume, and click OK.
5.
With the button symbol selected on the Stage, enter the instance name of handle_btn in
the Property inspector.
6.
Select the button, and select Modify > Convert to Symbol.
Be careful to select the movie clip behavior. This creates a movie clip with the button on
Frame 1.
7.
Select the movie clip, and enter volume_mc as the instance name in the Property inspector.
574
Creating Interaction with ActionScript
.
play_btn
stop_btn
Sound.start()
.
.
a_thousand_ways
and
playButton
stopButton
and
Sound.stop()
. The
objects start
methods, and also

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash 8

Table of Contents