Buongiorno a tutti,
devo creare un Carosello, pertanto dalla libreria ho aggiunto sullo stage 4 mc tramite AS con il seguente codice:
Testandolo, mi carica sullo stage un solo MC, dove sbalgio?
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:mc;
// attach icons to the stage
for (var i = 0; i < numOfItems; i++) {
t = new mc();
t.name = "mc"+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); }
Grazie mille

Rispondi quotando