# Script issue AS3 ; mc disappearing and needs to be smoother

**URL:** <https://forum.kirupa.com/t/script-issue-as3-mc-disappearing-and-needs-to-be-smoother/300956>\
**Category:** flash\
**Created:** [December 1, 2009, 8:54am UTC](https://forum.kirupa.com/t/script-issue-as3-mc-disappearing-and-needs-to-be-smoother/300956 "2009-12-01T08:54:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thevibe](https://avatars.discourse-cdn.com/v4/letter/t/d2c977/32.png) [@thevibe](https://forum.kirupa.com/u/thevibe)\
**Post date:** [December 1, 2009, 8:54am UTC](https://forum.kirupa.com/t/script-issue-as3-mc-disappearing-and-needs-to-be-smoother/300956/1 "2009-12-01T08:54:19Z")

</div>

Hi guys,

I found a script to make the animation follow the mouse movement and it needed to stay in fixed boundaries. I have 3 different mc 1 behind the other and moving at a different pace to give a illusion of perspective. But here are my issues;

1-It works but when I open a new window in the browser the mc(s) are disappearing.

2-And I would really need to ease or smooth the animation a little. I would like the mc(s) to continue to move and stop slowly after I already stopped moving the mouse.

Any ideas how to script both or even 1 of these ? Here’s the code I am using now;

function loopX(e:Event):void  
{  
var xDist:Number = mouseX - 24000

mc1.x = xDist \* -0.02;

}

addEventListener(Event.ENTER\_FRAME, loopbX);

function loopbX(e:Event):void

{  
var xDist2:Number = mouseX - 10000

mc2.x = xDist2 \* -0.05;

}

addEventListener(Event.ENTER\_FRAME, loopcX);

function loopcX(e:Event):void  
{  
var xDist3:Number = mouseX - 10000

mc3.x = xDist3 \* -0.1;

}

Maybe I even need to rewrite the whole script, but if you have this in mind, please try my code first to really understand the kind of movement I am looking for.

Thanks guys !!!
