Start the Flash program. Click "File," "New" on the main Flash menu bar. Click the file type "Flash File(ActionScript 3.0)" from the "New Document" dialog box. Click "OK."
Click the "Library" option from the "Window" menu.
Click "Sounds" in the "Common Libraries" menu within the "Window" menu.
Click one of the "sirens" sounds. Drag it to the Library panel that you already opened.
Right-click on your "sirens" sound file. Click "Properties" from the context menu. Check "Export for ActionScript." Replace the text in the "Class" text box with a new class named "Siren." Click "OK." Click "OK" again in the next "Class" dialog box.
Click "Properties" from the "Window" menu to display the Property Inspector. Click "Components" from the "Window" menu to display the Component Library.
Click and drag the "button" component from the Components Library to the Flash stage. Type the instance name "redsongs" into the instance name text box in the Properties Inspector. Click and drag another "button" component from the Components Library to the Flash stage. Type the instance name "Labelstop" into the instance name text box in the Properties Inspector.
Select "Actions" from the "Window" menu on the main Flash menu bar. Position your cursor on the first line of the Actions editor. Click and type in the following code to declare a Siren sound object and a soundChannel to process the sound through.
var sirensong:Siren = new Siren();
var sirenchannelone: SoundChannel = new SoundChannel();
Type the following code, starting at the next line in the Actions editor, to instruct Flash to play the siren sound when the redsongs button is clicked and to stop playing the siren when the Labelstop button is clicked.
redsongs.addEventListener(MouseEvent.CLICK, redplay);
Labelstop.addEventListener(MouseEvent.CLICK, violetplay);
function redplay (songevent:MouseEvent): void {
sirenchannelone = sirensong.play();
};
function violetplay (songevent:MouseEvent): void {
if (sirenchannelone){
SoundMixer.stopAll();
} ;
};
Copy and paste the following code into the Actions editor if you want to ensure that your sound creation and stopping program runs correctly.
var sirensong:Siren = new Siren();
var sirenchannelone: SoundChannel = new SoundChannel();
redsongs.addEventListener(MouseEvent.CLICK, redplay);
Labelstop.addEventListener(MouseEvent.CLICK, violetplay);
function redplay (songevent:MouseEvent): void {
sirenchannelone = sirensong.play();
};
function violetplay (songevent:MouseEvent): void {
if (sirenchannelone){
SoundMixer.stopAll();
} ;
};
Click "TestMovie" in the "Control" menu on the main Flash menu bar to start the siren sound movie. Click the redsongs button to play the sound siren and click the Labelstop button to stop the sound.