topical media & game development

talk show tell print

#graphic-player-10-cube-be-nascom-flash-component-SimpleGridGraphic.ax

#graphic-player-10-cube-be-nascom-flash-component-SimpleGridGraphic.ax [swf] [flash] flex


  package be.nascom.flash.component{
          
          import flash.display.Sprite;
  
          public class @ax-graphic-player-10-cube-be-nascom-flash-component-SimpleGridGraphic extends Sprite{
                  
                  public function @ax-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;
                                                  
                  }
                  
                  
                  
                  
          }
  }


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.