# Move carousel to mouse

**URL:** <https://forum.kirupa.com/t/move-carousel-to-mouse/318660>\
**Category:** flash\
**Created:** [January 26, 2011, 4:49pm UTC](https://forum.kirupa.com/t/move-carousel-to-mouse/318660 "2011-01-26T16:49:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![molly\_ferns](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@molly\_ferns](https://forum.kirupa.com/u/molly_ferns)\
**Post date:** [January 26, 2011, 4:49pm UTC](https://forum.kirupa.com/t/move-carousel-to-mouse/318660/1 "2011-01-26T16:49:53Z")

</div>

I have followed Lee’s tutorial and got results quite well but need to move the carousel as per teh mouse. At the moment I have modified this.angle -= this.\_parent.speed; where I made + to - to move it towards the mouse but this changes direction only once I cross the center. I want it to move even if I do not cross the middle ie if I am to the extreme right of the screen if I move the mouse towards the left, the carousel should move in the same direction even if it does not cross the middle. Please help. Code below.

Thanks

```auto
 
var numOfBalls:Number = 6;
var radiusX:Number = 610;
var radiusY:Number = 200;
var centerX:Number = Stage.width/2;
var centerY:Number = 960/2;
var speed:Number = 0.05
var home:MovieClip = this;

for(var i=1;i<=numOfBalls;i++)
{
 var t = home.attachMovie("item"+i,"b"+i,i+1);
 t.angle = i * ((Math.PI*2)/numOfBalls);
 t.onEnterFrame = mover;
}
 
function mover()
{
 this._x = Math.cos(this.angle) * radiusX + centerX;
 this._y = Math.sin(this.angle) * radiusY + centerY;
 var s = this._y /(centerY+radiusY);
 this._xscale = this._yscale = s*100;
 this.angle -= this._parent.speed;
 this.swapDepths(Math.round(this._xscale) + 100);
 
}
 
this.onMouseMove = function()
{
 speed = (this._xmouse-centerX)/10000;
} 

```
