Hi,
I have been doing the carousel tutorial by Lee Brimelow from gotoAndLearn.com, but have been trying to convert it to AS3.
I have gotten stuck and am hoping someone can help me out.
The problem is I’m trying to place four instances of the clip “item” onto the carousel, four of them are there but they are all in the same position.
you can see the swf and source fla here:
http://www.thelightdivided.co.uk/flash/index.html
http://www.thelightdivided.co.uk/flash/carousel.fla
The code I have so far is:
[COLOR=“DimGray”]var numOfItems:Number = 4;
var radiusX:Number = 200;
var radiusY:Number = 50;
var centerX:Number = this.stage.stageWidth / 2;
var centerY:Number = this.stage.stageHeight / 2;
var speed:Number = 0.02;
var t:item;
// attach icons to the stage
for (var i = 0; i < numOfItems; i++) {
t = new item();
t.name = “item_”+i;
// place each item equally around the circle
t.angle = i * ((Math.PI*2) / numOfItems);
t.addEventListener(Event.ENTER_FRAME, mover);
// add to stage
addChild(t);
}
function mover(evt:Event):void {
this.x = Math.cos(evt.target.angle) * radiusX + centerX;
this.y = Math.sin(evt.target.angle) * radiusY + centerY;
var s:Number = this.y / (centerY + radiusY);
this.scaleY = this.scaleX = s;
evt.target.angle += this.speed;
trace(evt.target.name);
trace(this.x);
}[/COLOR]
Many thanks
Chris