SHARE
TWEET

HGO: basic server communication

ulfben Mar 11th, 2012 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.net.URLRequest;
  2. import flash.net.URLVariables;
  3. import flash.net.URLLoader;
  4. import flash.net.URLRequestMethod;
  5.  
  6. var request:URLRequest = new URLRequest("http://www.ulfben.com/toupper.php"); //a friendly server-side script
  7. var variables:URLVariables = new URLVariables();
  8. variables["test"] = "test test";
  9. request.data = variables; //add the data to our containers
  10. request.method = URLRequestMethod.GET;
  11.  
  12. var loader:URLLoader = new URLLoader();
  13. loader.addEventListener(Event.COMPLETE, onComplete);
  14. loader.load(request);
  15.  
  16. function onComplete(event:Event)
  17. {
  18.         var loader:URLLoader = URLLoader(event.target);
  19.         var vars:URLVariables = new URLVariables(loader.data);
  20.         for (var parameter:String in vars) { //iterate through whatever the server passed back.
  21.                 trace(parameter + " = " + vars[parameter]);
  22.         }
  23. }
RAW Paste Data
Top