This is the script that is used in the tutorial:
var container:MovieClip = new MovieClip();
addChild(container);
root.transform.perspectiveProjection.fieldOfView = 120;
addEventListener(Event.ENTER_FRAME, addStar);
function addStar(e:Event):void
{
var mc:Star = new Star();
mc.x = stage.stageWidth / 2;
mc.y = stage.stageHeight / 2;
mc.z = 0;
mc.xVel = Math.random() * 4 - 2
mc.yVel = Math.random() * 4 - 2
mc.zVel = Math.random() * 4 - 2
mc.count = 0;
container.addChild(mc);
mc.addEventListener(Event.ENTER_FRAME, animate);
}
function animate(e:Event):void
{
e.currentTarget.x += e.currentTarget.xVel;
e.currentTarget.y += e.currentTarget.yVel;
e.currentTarget.z += e.currentTarget.zVel;
e.currentTarget.count++;
if (e.currentTarget.count = 100)
{
e.currentTarget.removeEventListener(Event.ENTER_FRAME, animate);
container.removeChild(MovieClip(e.currentTarget));
}
}
Hey, good tutorial mate helped me alot (:
Do you know how I could make it so the star would randomize its color?
123dsw666 1 year ago