I made one for you with how you DO .
function HTTPPost(_URL:String,_UVar:Object,_UEvent:Object){ var _Loader:URLLoader=new URLLoader(); _Loader.addEventListener(Event.COMPLETE,function():void{ if(_UEvent.hasOwnProperty("_Done")) _UEvent._Done(_Loader.data) }); _Loader.addEventListener(IOErrorEvent.IO_ERROR,function():void{ if(_UEvent.hasOwnProperty("_Error")) _UEvent._Error(_Loader.data) }); var _Variables:URLVariables=new URLVariables(); for(var i in _UVar){ _Variables[i]=_UVar[i] } var _Request:URLRequest=new URLRequest(_URL); _Request.data=_Variables; _Request.method=URLRequestMethod.POST; try{ _Loader.load(_Request); }catch(error:Error){ trace("Failed."); } }
Then you use it like this:
HTTPPost("URL",{"Variable_1":"Value"},{ "_Done":function(Message){ trace(Message)//print what URL file prints }, "_Error":function(Message){ trace(Message)//print an HT with error info } })
Hydro source share