You'll have to determine why an ObjectProxy is being created...
typically it's because an anonymous Object was returned and RemoteObject
had makeObjectsBindable="true" (which it is by default).
 
As for why an anonymous Object was returned - either something like a
java.util.Map was returned instead of the type you expected, or the
com.foo.Expr class was not available to the native deserializer in the
Flash Player at the time the response was received. 
 
Your AS3 (and Java, for the reverse situation) Expr class must also
possess a constructor that allows for no-arguments instantiation.
 
Depending on how classes are being loaded by your SWF (they can be
lazily loaded in Flex applications) the underlying call to
flash.net.registerClassAlias() (that is generated for you by the mxmlc
compiler because you added [RemoteClass(alias="com.foo.Expr")] metadata)
may not have executed before the response was received.
 
Another reason is that no reference was made to the ActionScript
com.foo.Expr class in your Flex application and hence the mxmlc compiler
never linked the class definition into the SWF. I don't think this is
the cause as you appear to make a reference to the class in the result
handler (and I imagine you also imported this class in order for it to
compile).
 
As a last ditch effort you could try making a static reference to your
class somewhere in your application, like:
 
private static var dep:Class = Expr;
 
or I guess you could even call flash.net.registerClassAlias on your own
and not rely on the generated code.
 
Actually, that begs the question, are you using MXML? Or are you working
with a pure ActionScript application?
 
Pete
 


________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of moonusamy
Sent: Friday, March 02, 2007 11:23 AM
To: [email protected]
Subject: [flexcoders] Re: Invoking RemoteObject method - Type Coercion
error




In the debugger:
event.result seems to be of type ObjectProxy
It shows a child of type Object that in turn contains a "root" Object
corresponding to a data member of my Expr class called root of a type
called Node.
In addition to this child object, event.result also shows a "root"
child Object. 
Since my method returns an Expr object, what I'd expect to see is
event.result to be of type Expr and to be able to do:
var expr:Expr = Expr(event.result);
var node:Node = expr.root;

Thanks
Vijay 

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "michael_ramirez44"
<[EMAIL PROTECTED]> wrote:
>
> Loop through the properties on the event.result to see if it does 
> contain the same public properties as you Expr.as class.
> 
> Michael Ramirez
> 
> --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> , "moonusamy" <vijay.k.ganesan@> 
> wrote:
> >
> > 
> > I'm using RemoteObject to invoke a server-side Java POJO method that
> > returns an object of type com.foo.Expr. I have Expr.java and Expr.as
> > with Expr.as annotated with [Bindable] and
> > [RemoteClass(alias="com.foo.Expr")]
> > 
> > I try to reference the returned value in the result handler in my 
> mxml
> > as follows:
> > private function fooResultHandler(event:ResultEvent):void
> > {
> > myexpr = Expr(event.result); 
> > 
> > TypeError: Error #1034: Type Coercion failed: cannot convert
> > mx.utils::[EMAIL PROTECTED] to com.foo.Expr
> > 
> > I expect event.result to be of type com.foo.Expr which it doesn't 
> seem
> > to be. What do I need to do to get to the object of type Expr that 
> my
> > method invocation returns?
> > 
> > Thanks
> > Vijay
> >
>



 

Reply via email to