Thanks Sam! One question. Is there any way to use the "destination" concept since I already have all of that defined on the FDS/Server side of things?
Thanks Hank On 4/26/07, Samuel R. Neff <[EMAIL PROTECTED]> wrote:
It's not well documented, but basically you create a NetConnection, set the encoding, and run NetConnection.call() where the first param is the fully qualified class and method name and remaining params are the params to pass on to the server side method. See classes below (watch wrapping). HTH, Sam ------------------------------------------- We're Hiring! Seeking a passionate developer to join our team building Flex based products. Position is in the Washington D.C. metro area. If interested contact [EMAIL PROTECTED] <careers%40blinemedical.com> package com.atellis.rpc { import flash.net.*; import flash.events.EventDispatcher; import flash.events.Event; import mx.rpc.AsyncToken; import mx.rpc.events.ResultEvent; public class RemotingServiceBase extends EventDispatcher { private var _connection:NetConnection; private var _remoteClassName:String; public function RemotingServiceBase(remoteClassName:String, encoding:uint = 3) { _remoteClassName = remoteClassName; _connection = new NetConnection(); _connection.objectEncoding = encoding; _connection.connect(URLInfo.instance.gatewayUrl); } protected function callService(method:String, eventPrefix:String, responder:Function, fault:Function, ... rest):AsyncToken { var token:AsyncToken = new AsyncToken(null); var r:DispatchingResponder = new DispatchingResponder( this, eventPrefix, token, responder, fault); var a:Array = new Array(rest.length + 2); a[0] = _remoteClassName + "." + method; a[1] = r; var i:uint = 2; for each(var o:Object in rest) { a[i++] = o; } _connection.call.apply(_connection, a); return token; } } } package com.atellis.rpc { import flash.net.Responder; import flash.events.EventDispatcher; import flash.events.Event; import mx.rpc.events.ResultEvent; import mx.rpc.AsyncToken; import mx.rpc.events.FaultEvent; import mx.rpc.Fault; public class DispatchingResponder extends Responder { private var _eventDispatcher:EventDispatcher; private var _eventPrefix:String; private var _token:AsyncToken; private var _responder:Function; private var _fault:Function; public function DispatchingResponder( eventDispatcher:EventDispatcher, eventPrefix:String, token:AsyncToken, responder:Function, fault:Function) { super(doRelay, doFault); _eventDispatcher = eventDispatcher; _eventPrefix = eventPrefix; _responder = responder; _fault = fault; _token = token; } private function doRelay(... rest):void { var event:ResultEvent = new ResultEvent( _eventPrefix + "Result", false, false, rest == null || rest.length != 1 ? rest : rest[0], _token, null); _eventDispatcher.dispatchEvent(event); if (_responder != null) { _responder(event); } } private function doFault(netFault:Object):void { var f:Fault; if(netFault) { var typ:Array = netFault.type.split("."); f = new Fault(typ[typ.length - 1], netFault.description, netFault.details); } else { f = new Fault("Unkown", "An error occurred and no fault details are available", "Unknown"); } var event:FaultEvent = new FaultEvent(_eventPrefix + "Fault", false, false, f, _token, null); _eventDispatcher.dispatchEvent(event); if (_fault != null) { _fault(event); } } } } ________________________________ From: flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com> [mailto: flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>] On Behalf Of hank williams Sent: Thursday, April 26, 2007 4:38 PM To: flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com> Subject: [flexcoders] accessing amf3 remote services using netConnection instead of removteObject Does anybody have any example on how to access amf3 remote services, which need to deal with new concepts like "destination", using a netConnection call? I am finding that remoteObject doesnt do everything I need. Thanks Hank