Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

starting a sound object

Status
Not open for further replies.

AudreyLucy

Technical User
Jul 19, 2002
42
US
Hello,

I'm attaching sound objects to a button.
I imported the sounds into the library...and typed identifiers for the linkage IDs. I've checked them on numerous occassions to verify that there are no typos.

I've defined the sound objects, in the first frame of the mc, the buttons reside in. Here's what the script looks like in that first frame:

mouseOver= new Sound();
mouseOver.attachSound("mouseOver01");


click= new Sound();
click.attachSound("click01");



Then I selected the button on the stage and applied these actions to the button:

on(rollOver){
if (playing!=true) {
_root.buttons_mc.mouseOver.start();
playing=true;}
}



on(rollOut){
_root.buttons_mc.mouseOver.stop("mouseOver01");
playing=false;
}



on (press){
if (playing!=true) {
_root.buttons_mc.click.start();
playing=true;}

}



I have had success making "mouseOver" (rollover sound) play when the cursor touches the button and stop when the cursor rolls off the button. But I'm having difficulty figuring out why the "click" (on press sound) won't play when the button is pressed.

Maybe someone can spot a typo or something that I haven't noticed yet...Can someone please help me out?

Thank you
 
OK....
To press the button, and activate the sound effect,
you have to have the cursor on it...that means that the rollover sound effect will play...So you have to add an action to the button in the "on (press)" state that wil turn OFF the "on (rollOver)" sound effect. Then add the sound effect for the "on(Press)" state of the button.

Here is the script incase I am not being very articulate:

on(rollOver){
if (playing!=true) {
_root.buttons_mc.mouseOver.start();
playing=true;}
}



on(rollOut){
_root.buttons_mc.mouseOver.stop("mouseOver01");
playing=false;
}




on(press){
_root.buttons_mc.mouseOver.stop("mouseOver01");
playing=false;
_root.buttons_mc.click.start();
playing=true;}



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top