I'm trying to convert an old AS2 game of mine into AS3. The old game is here:
http://www.flashninjaclan.com/zzz100_.php
Right now I'm having trouble with the background, I've duplicated the stars in the main time(note I am programming the game in the main timeline, no additional AS files).
But I can't figure out how to get them to fall and then reset to the top after they reach the bottom. The old AS2 code was just this:Code:import flash.display.*; var bigstar:thestar; var midstar:thestar; var smallstar:thestar; var stars: Array=new Array(); var i:int; for(i=1;i<=25;i++) { bigstar=new thestar(); bigstar.width=18; bigstar.height=13; bigstar.x = Math.random() * stage.stageWidth; bigstar.y = -30; addChild(bigstar); stars.push(bigstar); }
That was the code in the clip, which AS3 does not allow.Code:onClipEvent(load) { this._y=random(400); this._x=random(550); this.speed=random(2)+1; function reset() { this._x=random(550); this._y=-30; this.speed=random(2)+1; } } onClipEvent(enterFrame) { this._y+=this.speed; if(this._y>410) { this.reset(); } }


Reply With Quote