Advertisement
Masadow

HaxeFlixel remote loader state

May 14th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.21 KB | None | 0 0
  1. package state;
  2.  
  3. import flixel.FlxSubState;
  4. import flixel.text.FlxText;
  5. import flixel.FlxG;
  6. import flixel.ui.FlxButton;
  7. import haxe.remoting.HttpAsyncConnection;
  8.  
  9. /**
  10.  * ...
  11.  * @author Masadow
  12.  */
  13. class LoadState extends FlxSubState
  14. {
  15.     private var msg : String;
  16.     private var cb : Dynamic -> (Void -> Void) -> Void;
  17.     private var cmd : String;
  18.     private var args : Array<Dynamic>;
  19.  
  20.     public function new(msg : String, cb : Dynamic -> (Void -> Void) -> Void, cmd : String, args : Array<Dynamic>)
  21.     {
  22.         super();
  23.  
  24.         this.msg = msg;
  25.         this.cb = cb;
  26.         this.cmd = cmd;
  27.         this.args = args;
  28.     }
  29.  
  30.     override public function create():Void
  31.     {
  32.         super.create();
  33.  
  34.         var txt = new FlxText(0, 350, 640, msg, 24);
  35.         txt.alignment = "center";
  36.         add(txt);
  37.  
  38.         //Prepare the request
  39. //      var cnx = haxe.remoting.HttpAsyncConnection.urlConnect("http://" + GameClass.host);
  40.         var cnx = haxe.remoting.HttpAsyncConnection.urlConnect("http://haxe/BelugaDemo/bin");
  41.         // setup error handler
  42.         cnx.setErrorHandler( function(err) FlxG.log.error(Std.string(err)) );
  43.         cnx.Server.resolve(cmd).call(args, function(v) cb(v, done));
  44.     }
  45.  
  46.     private function done()
  47.     {
  48.         //Request is done, we can close this state
  49.         close();
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement