Hi, all i’m just learning AS3, hopes you guys can help me.
l just following the lesson on kirupa’s Classes and Movie Clips for AS3
http://www.kirupa.com/developer/flashcs3/movieclips_classes_AS3_pg4.htm
My question is:
im trying rewrite the for loop from time line to class
the problem is instead all the circle moving individually, they moving together. Here is the class.
package {
import flash.display.;
import flash.events.;
public class Main extends MovieClip {
var radians = 0;
var speed = 0;
var radius = 5;
public function Main()
{
speed = .01+.5Math.random();
radius = 2+10Math.random();
this.addEventListener(Event.ENTER_FRAME, RotateCircle);
for (var i:int = 0; i < 10; i++)
{
DisplayCircles();
}
}
function RotateCircle(e:Event)
{
radians += speed;
this.x += Math.round(radiusMath.cos(radians));
this.y += Math.round(radiusMath.sin(radians));
}
public function DisplayCircles()
{
{
var newCircle:redcir = new redcir();
this.addChild(newCircle);
newCircle.x = Math.random()*300;
newCircle.y = Math.random()200;
newCircle.alpha = .2+Math.random().5;
var scale:Number = .3+Math.random()*2;
newCircle.scaleX = newCircle.scaleY = scale;
}
}
}
}