home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / xwung.swf / scripts / com / lofiminds / xwung / NumberDraw.as < prev    next >
Encoding:
Text File  |  2008-09-03  |  2.1 KB  |  81 lines

  1. package com.lofiminds.xwung
  2. {
  3.    import com.lofiminds.gm.GameGraphics;
  4.    import com.lofiminds.gm.GameImage;
  5.    import com.lofiminds.gm.GameObject;
  6.    import com.lofiminds.gm.GameUtil;
  7.    import com.lofiminds.gm.Instances;
  8.    import flash.text.TextField;
  9.    import flash.text.TextFieldAutoSize;
  10.    import flash.text.TextFormat;
  11.    
  12.    public class NumberDraw extends GameObject
  13.    {
  14.       
  15.       private static var images:Array = initImages();
  16.        
  17.       
  18.       internal var number:int;
  19.       
  20.       private var scale:Number;
  21.       
  22.       public function NumberDraw()
  23.       {
  24.          super();
  25.          useCustomDraw = true;
  26.          scale = 0.25;
  27.       }
  28.       
  29.       private static function initImages() : Array
  30.       {
  31.          var _loc1_:Array = new Array();
  32.          var _loc2_:TextField = new TextField();
  33.          _loc2_.defaultTextFormat = new TextFormat("_Impact",30,16776960);
  34.          _loc2_.embedFonts = true;
  35.          _loc2_.autoSize = TextFieldAutoSize.LEFT;
  36.          var _loc3_:int = 0;
  37.          while(_loc3_ < 20)
  38.          {
  39.             _loc2_.text = (_loc3_ + 1).toString() + "x";
  40.             _loc1_.push(new GameImage(GameUtil.displayToBitmap(_loc2_)));
  41.             _loc3_++;
  42.          }
  43.          return _loc1_;
  44.       }
  45.       
  46.       override public function update() : void
  47.       {
  48.          if(scale < 1)
  49.          {
  50.             scale += 0.05;
  51.          }
  52.          else if(colorTransform.alphaMultiplier > 0)
  53.          {
  54.             colorTransform.alphaMultiplier -= 0.05;
  55.          }
  56.          else
  57.          {
  58.             Instances.destroy(this);
  59.          }
  60.       }
  61.       
  62.       override public function getClass() : Class
  63.       {
  64.          return NumberDraw;
  65.       }
  66.       
  67.       override public function onCustomDraw(param1:GameGraphics) : Boolean
  68.       {
  69.          var _loc2_:GameImage = null;
  70.          var _loc3_:int = number - 1;
  71.          if(_loc3_ >= images.length)
  72.          {
  73.             _loc3_ = int(images.length - 1);
  74.          }
  75.          _loc2_ = images[_loc3_] as GameImage;
  76.          param1.drawGameImage(_loc2_,0,x,y,0,this.colorTransform,scale);
  77.          return true;
  78.       }
  79.    }
  80. }
  81.