Activity 7: Sound Events

Intent

Students will learn to create mouseover events that trigger the playing of a sound.

Criteria

  • Students will complete the tutorial by having a rollover button that triggers a sound.
  • Students will then apply the tutorial to add four more sounds to the interface.

Task

Before you open Flash create a folder in your drive for this assignment. Save the supplied sound files into this folder. Sound Files You may also use your own sounds.

Setting the Stage

Open Flash. Create a Actionscript 3.0 document that is 500px wide and 100 px high.

Draw a rectangle that will become a button. The size should be 100 x 100 px and it should be placed at 0,0.

Convert the shape to a Button symbol by going to Modify/Convert to Symbol and choose Button.

Making the Button

Name: btnlowKick
Export for ActionScript
Class: lowKick
Base Class: flash.media.Sound

Also rename the instance btnlowKick in the Properties

Importing Sound to the Library

File/ Import to Library and choose lowKick.wav. It will appear in the Library Tab.

Double click in the space under AS linkages (by lowKick.wav) and type in lowKick1

Adding Code

Right Click on frame one and add the following code

import flash.events.MouseEvent;
var sndLowKick:lowKick1=new lowKick1();

btnlowKick.addEventListener(
MouseEvent.MOUSE_OVER,
function(evt:MouseEvent):void{
sndLowKick.play();
}
);

Save your file in the same folder as the sounds. Go CTRL + ENTER to test. Your sound should play when your mouse rolls over.

Assignment

Add four more buttons with four more sounds by repeating the steps to create the button and Importing the Sound. You will also need to add code. You may do so by declaring more variables and simply repeating the lower block of text, changing the name of the instance.
Post your “SoundBar” to your website when done.