package be.nascom.flash.component{ import flash.display.Sprite; public class graphic_player_10_cube_be_nascom_flash_component_SimpleGridGraphic extends Sprite{ public function graphic_player_10_cube_be_nascom_flash_component_SimpleGridGraphic(grid_width:uint,grid_height:uint,spacer:uint=10,grid_color:uint=0x000000){ super(); render(grid_width,grid_height,spacer,grid_color); } public function render(grid_width:uint,grid_height:uint,spacer:uint,grid_color:uint=0x000000):void{ this.graphics.clear(); this.graphics.lineStyle(1,grid_color); //vertical line this.graphics.moveTo(0,-grid_height); this.graphics.lineTo(0,grid_height); //horizontal line this.graphics.moveTo(-grid_width,0); this.graphics.lineTo(grid_width,0); this.graphics.lineStyle(1,grid_color,.5); var i:uint,tot:uint,first:int,cur:int; tot=grid_width*2/spacer; first=-Math.floor(tot/2*spacer); for(i=0;i<=tot;i++){ cur=first+i*spacer; this.graphics.moveTo(cur,-grid_height); this.graphics.lineTo(cur,grid_height); } tot=grid_height*2/spacer; first=-Math.floor(tot/2*spacer); for(i=0;i<=tot;i++){ cur=first+i*spacer; this.graphics.moveTo(-grid_width,cur); this.graphics.lineTo(grid_width,cur); } this.cacheAsBitmap=true; } } }