Advertisement
Guest User

Untitled

a guest
Oct 1st, 2011
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import nme.display.Sprite;
  2. import nme.Lib;
  3. import nme.events.Event;
  4. import nme.text.TextField;
  5. import nme.display.StageScaleMode;
  6.  
  7. class Application extends flash.display.Sprite
  8. {
  9.     public static inline var SCREEN_WIDTH = 640;
  10.     public static inline var SCREEN_HEIGHT = 480;
  11.    
  12.     public var tf: TextField;
  13.     public var i: Int;
  14.    
  15.     public function new()
  16.     {
  17.         super();
  18.    
  19.         addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
  20.        
  21.         graphics.beginFill(0xFF0000);
  22.         graphics.drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
  23.         graphics.endFill();
  24.     }
  25.    
  26.     public function onAddedToStage(event: Event)
  27.     {
  28.         this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
  29.         onStageResize(null);
  30.     }
  31.    
  32.     public function onStageResize(event: Event)
  33.     {
  34.         stage.scaleMode = StageScaleMode.EXACT_FIT;
  35.        
  36.         scaleX = stage.stageWidth / SCREEN_WIDTH;
  37.         scaleY = stage.stageHeight / SCREEN_HEIGHT;
  38.     }
  39.    
  40.     public static function main()
  41.     {
  42.         Lib.current.addChild(new Application());
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement