Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player


Summary:

Sound Effects in Flash

    ●     Make a Sound when you Drop Items on a Target Location.


Learn About:

Actionscript 3.0 Movie Clips Variables Sound

  •   This is the 6th tutorial in the Drag and Drop Project.


1 - Beginning Code    2 - Draggable Items    3 - Origin Code  4 - Reset Button    5 - Target Dropzone     6 - Sound  

Other People's Work:

Here are example of work inspired by this tutorial …


Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Boink Birds

drag-and-drop-example19.swf


Step #1: Download Sounds ~

 Get your sounds from: http://www.findsounds.com/ or you can download these …


Download and Save the audio somewhere you can find it.


Step #2: Import into your Flash File ~

Then open your project, go to: File > Import > Import to Library

Then open the Library (if necessary) by hitting: Cmd (⌘) +L

 Look for the Sound you imported library and Right-Click it.

right click

  Click ActionScript

sound properties

Then click Export for Actionscript.

export for actionscript

Also give the sound a simple identifier like "boing" - keep it simple, no periods or spaces.

class identifier


Step #3: Actionscript ~

Click on your Actions and Labels keyframe: keyframe actions

frame 1

Then hit F9 and open the Actions panel and look for the var codes …

var codes

Copy and paste this code below the other var codes:

              var myBoing:boing  = new boing (); 
              

The code looks like this:

var code


Step #4: Create an Instance of the Sound ~

Then scroll down a little further to find this code …

this is the code

This is the code that controls what happens when you Release the item …

Copy the new code …

				myBoing.play(); 
              

The final code should look like this:

hit test code


Step #9: Export your Work

Go to: File > Export > Export Movie or hit Cmd (⌘) +Enter and see if it works!

If you want more that one sound associated with different drag options the code would look like this:

                            
var myBoing:boing = new boing();
var myBuzz:buzz = new buzz();
var myBell:bell = new bell();

//

myBoing.play(); 
myBuzz.play();
myBell.play(); 

              

              

Last Step: Save and View your work ~

View your work by hitting the keyboard shortcut: Cmd(⌘)+Enter cmd enter

Save your work as - FIRST_NAME_LAST_NAME_PROJECT_NAME.fla]

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

 

•   ALWAYS save your projects using the following naming convention:
FIRST_NAME_LAST_NAME_PROJECT_NAME


  •   DO NOT name your project any other way - Improperly named projects will not receive credit and you will be sad.


  •   NEVER leave your work on the desktop or depend on a flash drive - instead, save your work in a folder you can find later - preferably on a virtual drive where it can be backed up.



Other Resources: http://www.danfergusdesign.com/classfiles/oldClasses/VCB324-richMedia2/exercises/matchingGame.php