home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / Jumper.swf / scripts / gamegraphics / GameText.as < prev    next >
Encoding:
Text File  |  2008-09-05  |  1.2 KB  |  48 lines

  1. package gamegraphics
  2. {
  3.    import flash.display.Sprite;
  4.    import flash.events.Event;
  5.    import flash.text.TextField;
  6.    import flash.text.TextFormat;
  7.    import flash.utils.Timer;
  8.    
  9.    public class GameText extends Sprite
  10.    {
  11.        
  12.       
  13.       private var timer:Timer;
  14.       
  15.       private var textField:TextField;
  16.       
  17.       public function GameText(text:String, x:int, y:int, format:TextFormat, fadeTime:int = 0)
  18.       {
  19.          super();
  20.          textField = new TextField();
  21.          textField.text = text;
  22.          if(fadeTime != 0)
  23.          {
  24.             timer = new Timer(fadeTime);
  25.             timer.addEventListener("timer",destroy);
  26.             timer.start();
  27.             addEventListener(Event.ENTER_FRAME,onEnterFrame);
  28.          }
  29.          textField.x = x;
  30.          textField.y = y;
  31.          GameGraphics.sprite.addChild(textField);
  32.          textField.setTextFormat(format);
  33.       }
  34.       
  35.       public function onEnterFrame(event:Event) : void
  36.       {
  37.          textField.y -= 0.5;
  38.       }
  39.       
  40.       public function destroy(event:Event) : void
  41.       {
  42.          timer.removeEventListener("timer",destroy);
  43.          timer.stop();
  44.          GameGraphics.sprite.removeChild(textField);
  45.       }
  46.    }
  47. }
  48.