Copy link to clipboard
Copied
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
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);
}
Copy link to clipboard
Copied
what is occuring that you do not expect?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
thank you but how could i write this line to remove the event listener from outside the 'diary' movieclip e.g. from the maintimeline
Copy link to clipboard
Copied
or make it so the soundclip is only played when the 'diary' movieclip is on the stage?
Copy link to clipboard
Copied
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);
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now