package com.almerblank.rmx.utils { import flash.net.Responder; import mx.managers.CursorManager; public class RMXGateway { // service calls public static const ADD_NEW_MEMBER:String = "Members.addMember"; public static const DELETE_MEMBER:String = "Members.deleteMember"; // gateway url private static const _gatewayURL:String = "http://www.yoururl.com/amfphp/gateway.php"; // gateway variables private static var _gateway:RemotingConnection; private static var _onSuccess:Function; private static var _onFault:Function; /** * The constructor, should not be used to instantiate a variable as this class is not meant to be instantiated. * * @return * */ public function RMXGateway() {} /** * The call() method is used to make a remoting call. * * @param command String path to the remote method being called. * @param success Function that is called on a successful communication with the server. * @param fault Function that is called when the server returns an error. * @param data Data object sent to the remote method * @param showBusyCursor Defaults to true to handle the busy cursor while communicating with the server. Set to false if you do not want a busy cursor. * */ public static function call(command:String, success:Function, fault:Function, data:* = null, showBusyCursor:Boolean = true):void { _gateway = new RemotingConnection(_gatewayURL); _onSuccess = success; _onFault = fault; var __responder:Responder = new Responder(onSuccess, onFault); if (data) { _gateway.call(command, __responder, data); } else { _gateway.call(command, __responder); } if (showBusyCursor) { CursorManager.setBusyCursor(); } } /** * Private method that handles firing the function that was specified in the call method and removes the busy cursor. * * @param result * */ private static function onSuccess(result:*):void { _onSuccess(result); CursorManager.removeBusyCursor(); } /** * Private method that handles firing the fault function that was specified in the call method and removes the busy cursor. * * @param fault * */ public static function onFault(fault:Object):void { _onFault(fault); CursorManager.removeBusyCursor(); } } } import flash.net.NetConnection; import flash.net.ObjectEncoding; class RemotingConnection extends NetConnection { public function RemotingConnection(sURL:String) { objectEncoding = ObjectEncoding.AMF0; if(sURL){ connect(sURL); } } public function AppendToGatewayUrl(s:String):void{ // } }