Created
March 19, 2013 13:25
-
-
Save jbuda/5196077 to your computer and use it in GitHub Desktop.
Flash Remoting Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.net.NetConnection; | |
import flash.net.Responder; | |
import RemotingEvent; | |
public class RemotingService extends NetConnection { | |
private var _service:NetConnection; | |
private var _Url:String; | |
private var _cfc:String; | |
private var _responder:Responder; | |
function RemotingService($url,$cfc) { | |
_Url = 'http://'+$url+'/flashservices/gateway'; | |
_cfc = $cfc; | |
_service = new NetConnection(); | |
_service.connect(_Url); | |
_responder = new Responder(onResult, onFault); | |
} | |
public function init($function:String,$vars:String=''):void { | |
_service.call(_cfc+'.'+$function,_responder,$vars); | |
} | |
private function onResult(e:Object):void { | |
dispatchEvent(new RemotingEvent(RemotingEvent.RESULT,e)); | |
} | |
private function onFault(fault:Object):void { | |
trace('REPORTING AN ERROR'); | |
trace('=============='); | |
for (var str:String in fault) { | |
trace(str+' : '+fault[str]); | |
} | |
trace('=============='); | |
for (var str2:String in fault['rootcause']) { | |
trace(str2+' : '+fault['rootcause'][str2]); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment