Posted By

sidneydekoning on 05/14/09


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

dubogii


Sending vars to server


 / Published in: ActionScript 3
 

  1. private function subscribeEmail():void {
  2.  
  3. // submit form
  4. var req:URLRequest = new URLRequest( _model.frameworkGateway );
  5. var vars:URLVariables = new URLVariables( );
  6. var proxy:URLLoader = new URLLoader( );
  7.  
  8. vars.action = "subscribe";
  9. vars.email = _emailField.text;
  10.  
  11. req.data = vars;
  12. req.method = URLRequestMethod.POST;
  13.  
  14. proxy.addEventListener( Event.COMPLETE , subscribeComplete );
  15. proxy.addEventListener( IOErrorEvent.IO_ERROR , ioError );
  16. proxy.load( req );
  17. // sendToURL( req)
  18. }
  19.  
  20. private function subscribeComplete(evt:Event):void {
  21. var content:String = evt.target.data;
  22. var strippedContent:Array = content.split( "res=" );
  23.  
  24. _errorText.text = strippedContent[1];
  25. }
  26.  
  27. private function ioError(io:IOErrorEvent):void {
  28.  
  29. Logger.info( "RESULT: " + io.target.data.res );
  30. _errorText.text = "Could not subscribe";
  31. }

Report this snippet  

You need to login to post a comment.