Ah, scoping issues J

 

You're using the onResult function which makes me think you've used Flash Remoting in the past.  We do not tend to use onResult in Flex because it can interfere with the way Flex manages RemoteObject calls.  If you want to attach a function to an individual call and not use the <mx:RemoteObject result="myFunc()" /> technique you can do something like this:

 

<mx:RemoteObject id="ro" result="event.call.resultFunc(event)" .../>

 

var call = ro.myFunc();

call.resultFunc = mx.utils.Delegate.create(this, myResultFunc);

 

The Delegate is what makes sure that your myResultFunc executes in the right context.

 

Check out the Flex J2EE chapter by Steven and Ali to get a real sense of an architecture that takes these ideas into account.

 

http://www.theserverside.com/articles/content/Flex/Flex_Chapter20.pdf

 

Matt

-----Original Message-----
From: sbyrne_dorado [mailto:[EMAIL PROTECTED]
Sent:
Tuesday, May 04, 2004 7:02 PM
To: [email protected]
Subject: [flexcoders] callback execution environment?

 

I'm trying to understand the environment that a call back function is
executing in.

I have called a remote object from ActionScript, via

     var call = remoteObject.myFunc();

Then I set a result handler function on the returned PendingCall instance:

     call.>

But when myFunc gets invoked, it gets passed in the result of the
remote object method invocation (expected) but does not seem to be
executing in the context of the invoking object, i.e. the value of
"this" is not what was present when I invoked "remoteObject.myFunc()".

I thought about annotating the PendingCall object with "this" in some
random property, but that doesn't help me since when myFunc is invoked
it is not being given the PendingCall instance.

Is there any way to have "myFunc" obtain the correct value for "this"?

Steve


Reply via email to