PDA

View Full Version : some sound help


Little Mac
03-19-2007, 11:12 PM
Hi guys, I'm new to the world of ActionScript and all things related so please forgive me if this sounds really basic. I have worked through the "Essential Training" titles for DreamWeaver and Fireworks and Flash and want to further my website now I have been biten by the "Bug". I want to add sound to my buttons in Flash 8 and have gone down the tutorial root of introducing the sound to my button on the "Down" state keyframe. I am not happy with results as my sound only occurs onRelease of the mouse button and I want to place the sound on the onPress of the mouse button. I have had a look through help files and have gone through the "Essential Training" titles from lynda.com and also Googling and not came up with anything useful exept learning a bit of terminology I can make sense of. The sound is just a simple "click" sound upon pressing the mouse button so any help would be great.

Thanking you in advance,

Best Regards

LM

FlashHed
03-20-2007, 07:51 AM
try this code:

/*
in order for this to work you need a your sound in the library, with its linkage name set to my_sound
*/

// Create a channel clip to store the sound
this.createEmptyMovieClip("ch_01",1);

// Create the sound object
sound_01 = new Sound("ch_01");

// Attach sound to the sound object
sound_01.attachSound("my_sound");

// Set volume
sound_01.setVolume(100);

// Play sound on button press
button.onPress = function(){
sound_01.start(0,0);
}

Little Mac
03-20-2007, 12:05 PM
Many thanks FlashHed!!!! :)

Worked first time. Thankyou for the reply.

Best Regards

LM