phantomon

DisegniMain.as

Nov 18th, 2011
4,485
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package  mx.com.disegni.display{
  2.    
  3.     import flash.display.Sprite;
  4.     import flash.display.Graphics;
  5.    
  6.     public class DisegniMain extends Sprite{
  7.        
  8.         protected var _stageWidth:Number;
  9.         protected var _stageHeight:Number;
  10.         protected var _backgroundColor:uint;
  11.         protected var _width:Number;
  12.         protected var _height:Number;
  13.  
  14.         public function DisegniMain(stageWidth:Number = 1280,stageHeight:Number = 800,backgroundColor:uint = 0xFFFFFF){
  15.             _width = _stageWidth = stageWidth;
  16.             _height = _stageHeight = stageHeight;
  17.             _backgroundColor = backgroundColor;
  18.         }
  19.         protected function paint(g:Graphics):void{
  20.             g.clear();
  21.             g.beginFill(_backgroundColor,1);
  22.             g.drawRect(0,0,_width,_height);
  23.             g.endFill();
  24.         }
  25.         public function repaint():void{
  26.             paint(this.graphics);
  27.         }
  28.         protected function layout():void{
  29.            
  30.         }
  31.         public function setSize(width:Number,height:Number){
  32.             _width = width;
  33.             _height = height;
  34.             repaint();
  35.         }
  36. ////////////////////////////////////////////////////////////////////////////////////////////
  37.         override public function get width():Number{
  38.             return _width;
  39.         }
  40.         override public function get height():Number{
  41.             return _height;
  42.         }
  43.         //Helpers Layout
  44.         public function X(n:Number):Number{
  45.             return (n -(_width - _stageWidth)/2);
  46.         }
  47.         public function Y(n:Number):Number{
  48.             return (n -(_height - _stageHeight)/2);
  49.         }
  50. ////////////////////////////////////////////////////////////////////////////////////////////
  51.     }
  52.    
  53. }
Advertisement