package scripts { import flash.display.MovieClip; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.*; public class main extends MovieClip { public function main() { var maxw:Number=maxw; var count:Number=count; var cols:Number=Math.ceil(stage.stageWidth/maxw); var colw:Number=Math.floor(stage.stageWidth/cols); stage.align=StageAlign.TOP_LEFT; stage.scaleMode=StageScaleMode.NO_SCALE; stage.addEventListener(Eventxt.RESIZE, arr); for (var i:Number = 0; i < count; i++) { var newBlock:box=new box(); newBlock.txt.width=newBlock.buttonewBlockackground.width=colw; if(i>0) { newBlock.x=i%cols*colw; newBlock.y=Math.floor(i/cols)*43; } else { newBlock.x=newBlock.y=0; } newBlock.txt.text=String(i); addChild(newBlock); } placeBlocks(); } function arr(e:Event):void { placeBlocks(); } function placeBlocks():void { var cols:Number=Math.ceil(stage.stageWidth/maxw); var colw:Number=Math.floor(stage.stageWidth/cols); for (var i:Number = 0; i < count; i++) { var newBlock:Object=getChildAt(i); newBlock.buttonewBlockackground.width=colw; newBlock.x=i%cols*colw; newBlock.y=Math.floor(i/cols)*43; } } } }