574
Creating Interaction with ActionScript
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
play_btn
.
5.
Add a button to the Stage and name it
stop_btn
.
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
(
song_sound
) and attaches the sound whose linkage identifier is
a_thousand_ways
. The
onRelease
event handlers associated with the
playButton
and
stopButton
objects start
and stop the sound by using the
Sound.start()
and
Sound.stop()
methods, and also
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.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...