Mark,

I spoke before I tested, which is always a mistake. I realized I am not
sure, in this scenario, how to set up the event handlers for the
remoteObject in this scenario.

Thanks
Hank

On 4/26/07, Mark Piller <[EMAIL PROTECTED]> wrote:

  Hey Hank,

I know you can invoke a remote object and pass the args in an array.
We just did this very thing in our data management implementation.
Here's some reference code:

// create remote object.
// notice the placeholder for the DESTINATION_NAME
var channelSet:ChannelSet = new ChannelSet();
var channel:Channel = ServerConfig.getChannel( "my-amf" );
channelSet.addChannel(channel);
var remoteObject:RemoteObject = new RemoteObject( DESTINATION_NAME );

remoteObject.channelSet = channelSet;

var remoteMethod:AbstractOperation;
// get a reference to the operation.
remoteMethod=remoteObject.getOperation( METHOD_YOU_NEED_TO_INVOKE );
// set the arguments. Notice it is an array
remoteMethod.arguments = args;
// invoke the function, get asyncToken
var asyncToken:AsyncToken = remoteMethod.send();

Hope this helps. Let me know if I am not answering your question :)

Thanks,
Mark

--- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, "hank
williams" <[EMAIL PROTECTED]> wrote:
>
> Hey Mark,
>
> No I am really just trying to create a very compact replacement for
> remoteObject. I want to create a single function that can do
everything that
> remoteObject does with instantiation setting destinations and
listeners etc.
> The problem is that actually invoking the remote function cant be
done with
> an args array with remote object.
>
> The reason I want to do all of this is to bottleneck all remoting
calls in
> this library I am building in one place. It is being ported to an
alternate
> platform and device and all the remoting stuff is going to have to be
> swapped out so I want to have it exist in one place and have all the
pieces
> of the code that need it to use this one routine. Because of the
args issue
> above remoteObject doesnt lend itself to this strategy.
>
> Hank
>
> On 4/26/07, Mark Piller <[EMAIL PROTECTED]> wrote:
> >
> > Hi Hank,
> >
> > Is the end goal to route the invocation via RTMP?
> >
> > Cheers,
> > Mark
> >
> > --- In flexcoders@yahoogroups.com 
<flexcoders%40yahoogroups.com><flexcoders%40yahoogroups.com>,

"hank
> > williams" <hank777@> wrote:
> > >
> > > 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 <srneff.lists@> 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 careers@ <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>
<flexcoders%40yahoogroups.com><flexcoders%40yahoogroups.com>
> > [mailto:
> > > > flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>
<flexcoders%40yahoogroups.com><flexcoders%40yahoogroups.com>] On
> > > > Behalf Of hank williams
> > > > Sent: Thursday, April 26, 2007 4:38 PM
> > > > To: flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>
<flexcoders%40yahoogroups.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
> > > >
> > > >
> > > >
> > >
> >
> >
> >
>

Reply via email to