Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Can't stop sound playing!

Guest
Apr 06, 2013 Apr 06, 2013

The problem is that I have a sound that plays inside a movieclip when the play head enters a frame (inside the movieclip), this is controlled by an event listener:

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeToGoToNextPreviousFrame_4);

function fl_SwipeToGoToNextPreviousFrame_4(event:TransformGestureEvent):void

{

    if(event.offsetX == 1)

    {

        // swiped right

        prevFrame();

    }

    else if(event.offsetX == -1)

    {

        // swiped left

        nextFrame();

    }

}

when the playhead in the maintime line, goes back to a frame before the one containing said movieclip,
swiping still causes this sound to play.


I am both unsure as to why this happens and home to stop it from happening

Any suggestions would be greatly appreciated

Thanks

TOPICS
ActionScript
742
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 06, 2013 Apr 06, 2013

in the frame that contains your diary movieclip, use:

diary.addEventListener(Event.REMOVE_FROM_STAGE,removeF);

function removeF(e:Event):void{

stage.removeEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeToGoToNextPreviousFrame_4);

}

Translate
Community Expert ,
Apr 06, 2013 Apr 06, 2013

what is occuring that you do not expect?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 06, 2013 Apr 06, 2013

sorry I should have been clearer,

so I want the swipe gesture and the sound to play in the movieclip 'diary' on frame 5 (of the main timeline)

however when the playhead goes back to frame 3, which does not have the movieclip 'diary' in it, I do not want the sound to play and I do not need the swipe gesture.
Would I need to, for instance, remove the eventlistener before going back to frame 3?

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 06, 2013 Apr 06, 2013

yes, when you no longer want the swipe gesture to no longer call the function shown in your first message, use:

stage.removeEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeToGoToNextPreviousFrame_4);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 06, 2013 Apr 06, 2013

thank you but how could i write this line to remove the event listener from outside the 'diary' movieclip e.g. from the maintimeline

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 06, 2013 Apr 06, 2013

or make it so the soundclip is only played when the 'diary' movieclip is on the stage?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 06, 2013 Apr 06, 2013
LATEST

in the frame that contains your diary movieclip, use:

diary.addEventListener(Event.REMOVE_FROM_STAGE,removeF);

function removeF(e:Event):void{

stage.removeEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeToGoToNextPreviousFrame_4);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines