Skip to main content
Inspiring
November 11, 2022
Question

Canvas: Sound plays twice second time mouse over

  • November 11, 2022
  • 1 reply
  • 403 views

https://dolanddesign.com/FoodBank/AAAHH/

Click on Pip's Carb Coaster

 

File attached. On mouseover, I have the "coaster" mc play. On mouseout, I tell it to go back to frame 1. However, when I rollover once again, this time you'll see that the "bounce" sound plays twice "boi-boing" instead of "boing".

 

also, I can't figure out why none of the other buttons are working. It was working fine and the file was published and deliverd. Now that I'm doing version 2, suddenly none work. I miraculously got the top-right to work, but the others are just dead yet they seem identical in code.

 

Actually, it won't let me attach a fla so here it is: 

https://drive.google.com/file/d/1LcpqZ2Wl_3IV2MpVUpCl3BNuRozmL3_C/view?usp=share_link

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
November 11, 2022

don't add listeners more than once.

 

eg, one way to prevent re-adding a listener defined in a frame that plays more than once:

 

var alreadyExecuted;

if(!alreadyExecuted){

alreadyExecuted=true;

this.whatever.addEventListener(...

}

beatbumAuthor
Inspiring
November 12, 2022

"don't add listeners more than once."

I only have this code:


var _this = this;

stage.enableMouseOver(3);
this.button_coaster.on('mouseover', function(){
_this.coaster.play();

});

stage.enableMouseOver(3);
this.button_coaster.on('mouseout', function(){
_this.coaster.gotoAndStop(0);
//createjs.Sound.stop();
});

 

Note: it only plays that boing sound doubled the second time and on when you mouse over. You'll notice it does not double up the skidding sound or the taking off sound. Just those boings. ??

beatbumAuthor
Inspiring
November 12, 2022

Ok well I fixed it by removing the sounds from the individual fruit MCs, and placing them instead on their parent level. I still don't know why it was firing doubles when the sound was inside of each fruit. 

 

Now, why don't the other buttons work? Another Flash mystery to be solved...