Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function fullCall(url:String, postData:String=null, method:String = URLRequestMethod.GET):Signal{
- var request:URLRequest = new URLRequest(url);
- if(postData!=null){
- var data:ByteArray = new ByteArray();
- data.writeMultiByte(postData, INPUT_CP);
- request.method = method;
- request.data = data;
- }
- var ldr:URLLoader= new URLLoader();
- ldr.addEventListener(Event.COMPLETE, onRequestComplete);
- ldr.addEventListener(IOErrorEvent.IO_ERROR, onRequestFailure);
- ldr.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityViolation);
- ldr.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
- var sig:Signal = new Signal();
- function onRequestComplete(e:Event):void
- {
- sig.dispatch(e.target.data)
- }
- function httpStatusHandler(event:HTTPStatusEvent):void {
- trace("httpStatusHandler: " + event);
- trace("status: " + event.status);
- }
- /////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////
- function onRequestFailure(e:Event):void{
- sig.dispatch(e.target.data)
- }
- /////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////////////
- function onSecurityViolation(e:Event):void{
- }
- ldr.load(request);
- return sig;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement