EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 103

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Creating interactivity and visual effects 103
7 Select Frame 1 in the main Timeline, and select Window > Development Panels > Actions. Add
the following code to the Actions panel:
speaker.stop();
song = new Sound();
song.onSoundComplete = function() {
speaker.stop();
};
song.attachSound("a_thousand_ways");
playButton.onRelease = function() {
song.start();
speaker.play();
};
stopButton.onRelease = function () {
song.stop();
speaker.stop();
}
This code first stops the speaker movie clip. It then creates a new Sound object (song) and
attaches the sound whose linkage identifier is
a_thousand_ways. Next, it defines an
onSoundComplete handler for the song object, which stops the speaker movie clip once the
sound has finished. Lastly,
onRelease handlers associated with the playButton and
stopButton objects start and stop the sound using the Sound.start() and Sound.stop()
methods, and also play and stop the
speaker movie clip.
8 Select Control > Test Movie to hear the sound.
To create a sliding volume control:
1 Drag a button to the Stage.
2 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 its first frame.
3 Select the movie clip and select Edit > Edit Selected.
4 Select the button and select Window > Development Panels > Actions.
5 Enter the following actions:
on (press) {
startDrag(this, false, left, top, right, bottom);
}
on (release) {
stopDrag();
}
The startDrag() parameters left, top, right, and bottom are variables set in a clip action.
6 Select Edit > Edit Document to return to the main Timeline.
7 Select the movie clip on the Stage.

Table of Contents

Related product manuals