# swapDepths Problem with Flash carousel

**URL:** <https://forum.kirupa.com/t/swapdepths-problem-with-flash-carousel/239819>\
**Category:** flash\
**Created:** [September 26, 2007, 10:03am UTC](https://forum.kirupa.com/t/swapdepths-problem-with-flash-carousel/239819 "2007-09-26T10:03:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steveo](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@Steveo](https://forum.kirupa.com/u/Steveo)\
**Post date:** [September 26, 2007, 10:03am UTC](https://forum.kirupa.com/t/swapdepths-problem-with-flash-carousel/239819/1 "2007-09-26T10:03:49Z")

</div>

Hi

I’ve just completed a great video tutorial from [http://www.gotoandlearn.com/](http://www.gotoandlearn.com/) and have now made my own carousel, but it has one problem. The mc’s do not swap depths properly which kinda kills the whole illusion…

here’s my code,

```auto

var numOfItems:Number = 10;
var radiusX:Number = 250;
var radiusY:Number = 75;
var centerX:Number = Stage.width/2;
var centerY:Number = Stage.height/2;
var speed:Number = 0.05;

for(var i=0;i<numOfItems;i++) {
    var t = this.attachMovie("item","item"+1, i+1);
    t.angle = i * ((Math.PI*2)/numOfItems);
    t.onEnterFrame = mover;
}

function mover() {
    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.angle += this._parent.speed;
    this.swapDepths(Math.round(this._xscale)+100);
}

this.onMouseMove = function() {
    speed = (this._xmouse-centerX)/9000;
}

```

my stage is 1000 x 1000

the mc’s flash back and forward when they overlap at the edges of the carousel.

any ideas what’s going wrong?

Cheers for your help

Steve
