# Click, moveTo then go back?

**URL:** https://forum.kirupa.com/t/click-moveto-then-go-back/299491
**Category:** Uncategorized
**Created:** [November 5, 2009, 5:55pm UTC](https://forum.kirupa.com/t/click-moveto-then-go-back/299491 "2009-11-05T17:55:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Dr\_Abner\_Mellon](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@Dr\_Abner\_Mellon](https://forum.kirupa.com/u/Dr_Abner_Mellon)
#### Post date: [November 5, 2009, 5:55pm UTC](https://forum.kirupa.com/t/click-moveto-then-go-back/299491/1 "2009-11-05T17:55:26Z")

</div>

Below is what I’m doing, But I need to add a “close” button that will move the tabBtn back. And also replay the video?

```auto

tabBtn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void {
    videoPlayer.stop();
}

// start the animation when tabBtn is clicked
tabBtn.addEventListener(MouseEvent.CLICK, moveTo);

var currentFrameCount:int;
var totalFrameCount:int = 20;
var destinationX:Number = 302;
var destinationY:Number = 100;
var initialX:Number;
var initialY:Number;

var distanceX:Number;
var distanceY:Number;

function moveTo (evt:MouseEvent):void
{
    currentFrameCount = 0;
   
    initialX = tabBtn.x;
    initialY = tabBtn.y;
    
    distanceX = destinationX - initialX;
    distanceY = destinationY - initialY;

    tabBtn.addEventListener(Event.ENTER_FRAME, animateMoveTo);
}

function animateMoveTo (evt:Event):void
{
   
    currentFrameCount++;
   
    if (currentFrameCount < totalFrameCount){
      
        var progress:Number = currentFrameCount/totalFrameCount;
        
        tabBtn.x = initialX + distanceX*progress;
        tabBtn.y = initialY + distanceY*progress;
    }else{
        
        tabBtn.x = destinationX;
        tabBtn.y = destinationY;
        
        tabBtn.removeEventListener(Event.ENTER_FRAME, animateMoveTo);
    }
   
}

```
