# 2 enterframe functions for one movieclip

**URL:** https://forum.kirupa.com/t/2-enterframe-functions-for-one-movieclip/331847
**Category:** flash
**Created:** [November 6, 2013, 9:38am UTC](https://forum.kirupa.com/t/2-enterframe-functions-for-one-movieclip/331847 "2013-11-06T09:38:34Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Chibi\_Hashmin](https://avatars.discourse-cdn.com/v4/letter/c/6bbea6/32.png) [@Chibi\_Hashmin](https://forum.kirupa.com/u/Chibi_Hashmin)
#### Post date: [November 6, 2013, 9:38am UTC](https://forum.kirupa.com/t/2-enterframe-functions-for-one-movieclip/331847/1 "2013-11-06T09:38:34Z")

</div>

Hi Guys! I’m new here. This is actually my first post. I really need help.  
I’m using enterframe to move/ease movie clips into position after dragging them. I already have a code for this which I got from Bill Trikojus at Swinburne.My problem is, I also want to be able to reset all movie clips to their original position with a button. I tried creating another enterframe function for the movie clip but it contradicts with the first enterframe function. Is there a proper way to do this?

Here’s a part of the code I’m using

```auto

    clip.myHomeX = clip.x;
    clip.myHomeY = clip.y;
    clip.myFinalX = targ.x;
    clip.myFinalY = targ.y;
    clip.scaleX = .8;
    clip.scaleY = .8;
    
    function slide(e:Event):void{
        if (!e.target.beingDragged && !e.target.onTarget) {
            e.target.x -= (e.target.x-e.target.myHomeX)/5;
            e.target.y -= (e.target.y-e.target.myHomeY)/5;
                clip.scaleX += (.8-clip.scaleX)/5;
                clip.scaleY += (.8-clip.scaleY)/5;
        } else if (!e.target.beingDragged && e.target.onTarget) {
            e.target.x -= (e.target.x-e.target.myFinalX)/5;
            e.target.y -= (e.target.y-e.target.myFinalY)/5;
                clip.scaleX += (1-clip.scaleX)/5;
                clip.scaleY += (1-clip.scaleY)/5;
}
}

clip.addEventListener(Event.ENTER_FRAME,slide)
save_btn.addEventListener(MouseEvent.CLICK, saveClick);

function saveClick(e:MouseEvent):void{
clip.addEventListener(Event.ENTER_FRAME, slideAgain)
}

function slideAgain(e:Event):void{
    if (!clip.beingDragged && clip.onTarget) {
            clip.x -= (clip.x-clip.myHomeX)/5;
            clip.y -= (clip.y-clip.myHomeY)/5;
            clip.scaleX += (.8-clip.scaleX)/5;
            clip.scaleY += (.8-clip.scaleY)/5;
}
}

```
