Flash Drag and Drop with Sound
This tutorial is for Flash MX 2004.
My students wanted to make a drag and drop application similar to the ABC's Mixi dress up and using my tutorial found here: http://portal.newman.wa.edu.au/technology/11DigMed/html/flash/dragdrop/index.htm
but they wanted the sounds to play when they pick up an item and dropped an item.
Recipe
Step 1 Create a simple button for what you want to drag and drop. Insert-New Symbol. Make sure you select button. Draw your object.
Step 2 Import your sounds into the Library. File - Import - Import to Library.
Step 3 For each sound, right click the sound and choose Linkage to show the Linkage properties. Make sure that the "Export for ActionScript" check box is ticked and you have a name for the Identifier.
Step 4 Create a simple movie and copy your button into it.
Add the following action script for the button.
on (press) {
applause_sound.stop();
space_sound = new Sound();
space_sound.attachSound("space");
play();
space_sound.start(0,1);
startdrag("",true);
}
on (release, releaseOutside) {
space_sound.stop();
applause_sound = new Sound();
applause_sound.attachSound("applause");
play();
applause_sound.start(0,1);
stopdrag();
}
Note:
-
My two sounds had the following identifiers: applause and space
-
You must stop any running sound before starting a new sound eg applause_sound.stop();
-
One sound is started on press and the other on release
-
space_sound.start(0,1); allows the sound to be played only 1 time
-
startdrag("",true); allows the object to be dragged
-
stopdrag(); allows you to relase the object.
Step 5 Copy your movie into the scene where it is to be dragged.
Click the link to see my working model drag_drop_with-sound
Comments (0)
You don't have permission to comment on this page.