# Carousel Help

**URL:** <https://forum.kirupa.com/t/carousel-help/248543>\
**Category:** flash\
**Created:** [January 9, 2008, 2:15pm UTC](https://forum.kirupa.com/t/carousel-help/248543 "2008-01-09T14:15:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rai\_kane3](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@rai\_kane3](https://forum.kirupa.com/u/rai_kane3)\
**Post date:** [January 9, 2008, 2:15pm UTC](https://forum.kirupa.com/t/carousel-help/248543/1 "2008-01-09T14:15:16Z")

</div>

I have used the tutorial from [gotoandlearn.com](http://gotoandlearn.com) to create a carousel. I have modified it so that it does not spin until the mouse actually moves however its terribly chunk and I have realised that it doesn’t really do what I want it to do.

so

I have a circle of items and I want it so they dont move until you click on one of the words it moves to the front in a clock wise motion, im totally lost, here is the action script.

items contains a dynamic textfield with the word in it.

> 

var numOfItems:Number = 10;  
var radiusX:Number = 232;  
var radiusY:Number = 75;  
var centerX:Number = Stage.width/2;  
var centerY:Number = Stage.height/2;  
var speed:Number = 0.05;  
var moving:Boolean = true;  
var boxes:Array = new Array();  
[//math.PI](https://math.PI) is equal to the radium of 360 degrees devided by the number of items.  
for(var i=0;i\<numOfItems;i++)  
{  
var t = this.attachMovie(“item”,“item”+i,i+1);  
t.angle = i \* ((Math.PI\*2)/numOfItems);  
t.onEnterFrame = setPos;  
boxes.push(t);  
t.onRelease = clicked;  
}  
//cos = angle which presents the ratio of the sides of item x axis  
//sin = angle which presents the ratio of the sides of item y axis  
function clicked()  
{  
trace(“pos”+this.angle);  
}

function stopMoving()  
{  
moving = false  
trace(“timer”)  
clearInterval(stopTimer);  
}

function mover()  
{  
for(var i=0;i\<numOfItems;i++)  
{  
boxes\*.angle += boxes\*.\_parent.speed;  
}  
}

function setPos()  
{  
if(moving)  
{  
this.\_x = Math.cos(this.angle) \* radiusX + centerX;  
this.\_y = Math.sin(this.angle) \* radiusY + centerY;  
var s:Number = this.\_y / (centerY+radiusY);  
this.\_xscale = this.\_yscale = s \*100;  
this.swapDepths(Math.round(this.\_xscale) + 100);  
}  
}

this.onMouseMove = function()  
{  
mover();  
speed = (this.\_xmouse-centerX)/1500;  
}

var stopTimer = setInterval(this, stopMoving, 100);
