Ok so what I’m trying to do is Instance a rectangle and move it across the screen, and as it’s moving, make more rectangles. For some reason though, it’s only making one rectangle, and the timer is taking way more than what I thought would be 100 milliseconds. Any help would be appreciated. >:D
var level:int = 1;
var i:int = 0;
var buildings:Array = new Array();
var myTimer:Timer = new Timer(100);
myTimer.addEventListener(TimerEvent.TIMER, go);
myTimer.start();
function go(event:TimerEvent):void {
if (i % 100 == 0) {
var randomSize:int = Math.floor(Math.random() * 100 - (level * 10)) + (40 - level);
var myRect:Shape = new Shape();
myRect.graphics.beginFill(000000, 1);
myRect.graphics.drawRect(0, 0, randomSize, 75);
myRect.graphics.endFill();
myRect.x = stage.stageWidth;
myRect.y = stage.stageHeight - 75;
addChild(myRect);
buildings* = myRect;
}
i ++;
for (var a:Number=0; i<=buildings.length; i++) {
buildings[a].x -= 100;
trace("MOVING BUILDING");
}
}