Markavian

Untitled

Nov 27th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.54 KB | None | 0 0
  1. package net.mkv25.test;
  2.  
  3. import flash.display.Sprite;
  4. import flash.events.Event;
  5. import flash.Lib;
  6. import flash.text.TextField;
  7. import flash.text.TextFieldType;
  8.  
  9. class Main extends Sprite
  10. {
  11.     var inited:Bool;
  12.  
  13.     /* ENTRY POINT */
  14.    
  15.     function resize(e)
  16.     {
  17.         if (!inited) init();
  18.         // else (resize or orientation change)
  19.     }
  20.    
  21.     function init()
  22.     {
  23.         if (inited) return;
  24.         inited = true;
  25.        
  26.         var HH = stage.stageHeight / 2;
  27.         var FW = stage.stageWidth;
  28.        
  29.         var g = this.graphics;
  30.         g.beginFill(0xFFFFFF);
  31.         g.drawRect(0, 0, FW, HH);
  32.         g.endFill();
  33.        
  34.         g.beginFill(0x000000);
  35.         g.drawRect(0, HH, FW, HH);
  36.         g.endFill();
  37.        
  38.         var textInput:TextField = new TextField();
  39.         textInput.type = TextFieldType.INPUT;
  40.         textInput.selectable = true;
  41.         textInput.width = FW;
  42.         textInput.height = HH;
  43.        
  44.         var format = textInput.defaultTextFormat;
  45.         format.size = 60;
  46.         textInput.defaultTextFormat = format;
  47.         textInput.setTextFormat(format);
  48.        
  49.         addChild(textInput);
  50.     }
  51.  
  52.     /* SETUP */
  53.  
  54.     public function new()
  55.     {
  56.         super();   
  57.         addEventListener(Event.ADDED_TO_STAGE, added);
  58.     }
  59.  
  60.     function added(e)
  61.     {
  62.         removeEventListener(Event.ADDED_TO_STAGE, added);
  63.         stage.addEventListener(Event.RESIZE, resize);
  64.         #if ios
  65.         haxe.Timer.delay(init, 100); // iOS 6
  66.         #else
  67.         init();
  68.         #end
  69.     }
  70.    
  71.     public static function main()
  72.     {
  73.         // static entry point
  74.         Lib.current.stage.align = flash.display.StageAlign.TOP_LEFT;
  75.         Lib.current.stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
  76.         Lib.current.addChild(new Main());
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment