# removeEventListener/disable button during tween problem

**URL:** <https://forum.kirupa.com/t/removeeventlistener-disable-button-during-tween-problem/297093>\
**Category:** flash\
**Created:** [September 25, 2009, 12:59pm UTC](https://forum.kirupa.com/t/removeeventlistener-disable-button-during-tween-problem/297093 "2009-09-25T12:59:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![siosio](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@siosio](https://forum.kirupa.com/u/siosio)\
**Post date:** [September 25, 2009, 12:59pm UTC](https://forum.kirupa.com/t/removeeventlistener-disable-button-during-tween-problem/297093/1 "2009-09-25T12:59:41Z")

</div>

[COLOR=black][FONT=Verdana]Help Please!! [/FONT][/COLOR]

[COLOR=black][FONT=Verdana]Hi, I’ve been stuck on a little problem for some time now. Basically, I have a movieclip on the stage called slide\_mc that gets tweened left or right when next\_btn or back\_btn are pressed. Slide\_mc is a long rectangular strip that has different images on it. The idea is, you press next or back to show different parts of this strip. There are two panels on a layer above it to hide the extra parts of the strip from view. I needed the slide\_mc to move forwards and backwards seamlessly as if it is one long continuous strip. I did this using actionscript3 and its x coordinate. The images on slide\_mc are equally spaced so I just set the tween to move by a certain number of x values. The problem is if you press the next button before the previous tween has finished it progresses again by that same value which ends up moving the slide\_mc to a random position, perhaps covering some of the image. How can I disable the next and back buttons until the Actionscript tween has finished what its doing and then enable them again for the next tween? The end product is supposed to be a gallery. Obviously it would be better to use a UiLoader to display the images to keep the file size down, but I couldn’t think of a way to load the right images while still allowing the slide\_mc to move forward AND backwards. [/FONT][/COLOR]  
[COLOR=black][FONT=Verdana]I have only started using flash so I’m sure there’s probably something obvious that I’m missing. If anybody can help me with my original code or suggest a better way to achieve this effect I would really appreciate it![/FONT][/COLOR]  
[COLOR=black][FONT=Verdana]Thanks, [/FONT][/COLOR]  
[FONT=Calibri][SIZE=3]here’s my code:[/SIZE][/FONT]  
next\_Btn.addEventListener(MouseEvent.CLICK,moveLeft);  
back\_Btn.addEventListener(MouseEvent.CLICK,moveRight);  
import fl.transitions.Tween;  
import fl.transitions.easing.\*;  
import fl.transitions.TweenEvent;

var scrollTween:Tween;  
function moveLeft(event:MouseEvent):void{

clock.gotoAndPlay(“play”);  
var currentX:Number = slide.x;  
var newX:Number = currentX - 385.9;  
trace("Current Position is: " + currentX);  
//trace(newX);  
if(currentX != -702.9){

scrollTween = new Tween(slide,“x”,Regular.easeOut,currentX,newX,59,false);  
currentX = newX;

}  
trace("Position is Now: " + currentX);

}  
function moveRight(event:MouseEvent):void{  
var currentX:Number = slide.x;  
var newX:Number = currentX + 385.9;

trace("Current Position is: " + currentX);  
//trace(newX);  
if(currentX != 68.85){  
scrollTween = new Tween(slide,“x”,Regular.easeOut,currentX,newX,59,false);  
currentX = newX;

}  
trace("Position is Now: " + currentX);  
}
