Skip to main content
Inspiring
July 14, 2010
Question

sound doesn't stop SOMETIMES?

  • July 14, 2010
  • 1 reply
  • 1738 views

Hi... I would really  appreciate some help with this please... Thank you very much ahead of  time!!!

I have movie clip buttons with a dynamic sound withing a  slide show. Slide show consists of 3 movie clips connecting on frames  1, 300 and 900. The movie clip buttons with sound over are within the  connecting movie clips. My problem is that although the sound and  buttons work fine most of the time, sometimes, particularly if I mouse  over the button wile it's transitioning on one of the connecting frames  (300, 900), the sound doesn't stop... I'm sure I'm missing something in  the Action Script?? Here's the script I'm using for the buttons:


stop();

import  flash.display.MovieClip;
import flash.events.MouseEvent;

var  req:URLRequest = new URLRequest("blend.mp3");
var sound:Sound = new  Sound();
var controller:SoundChannel;

function  soundLoaded(event:Event):void
{
    controller = sound.play();
     controller.stop();

this.addEventListener(MouseEvent.ROLL_OVER,  playSound);
this.addEventListener(MouseEvent.ROLL_OUT, stopSound);
this.addEventListener(MouseEvent.CLICK,  onClickHandler);
this.addEventListener(MouseEvent.MOUSE_DOWN,  onPressHandler);
this.addEventListener(MouseEvent.MOUSE_UP,  onReleaseHandler);

}

// if you want a hand cursor
this.buttonMode  = true;
this.useHandCursor = true;

function  playSound(myEvent:MouseEvent) {
    trace("On");
     this.gotoAndPlay("one");
    controller = sound.play();
}
function  stopSound(myEvent:MouseEvent) {
    trace("Out");
     this.gotoAndPlay("two");
    controller.stop();

   

}
function  onClickHandler(myEvent:MouseEvent) {
    trace("I waited for Press  AND Release!!!");
    this.gotoAndPlay("three");
}
function  onPressHandler(myEvent:MouseEvent) {
    trace("Press");
}
function  onReleaseHandler(myEvent:MouseEvent) {
    trace("Release");
     this.gotoAndPlay("four");
}


sound.addEventListener(Event.COMPLETE,  soundLoaded);
sound.load(req);

Thank you!!

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
July 14, 2010

if your rollout is detected, the sound should stop.  if you're not careful, your rollout may not be detected but then i would expect you would detect that by failing to see that trace "Out" and frame "two" wouldn't play.

Inspiring
July 14, 2010

Thanks for your replay Kglad! But what do you mean by me "bening careful"? I'm not sure exactly how I may or may not be? The sound doesn't stop if I"m mousing over the button when the transition comes up, than whenI click on the button (I can go between transitions via buttons as well) and I mouse over these buttons again - the Trace On and Out is all in tact but the sound still plays... Hope this makes sense?

kglad
Community Expert
Community Expert
July 14, 2010

the code you showed only executes once, correct?  ie, the frame that contains that code only plays once and the playhead never re-enters that frame.