views:

11

answers:

2

I make a remote call to a method defined on my Java back end (using BlazeDS). This method returns a MyType object. On the Flex side the return value is of course wrapped inside a ResultEvent object and stored as an Object. The debugger clearly shows that the ResultEvent contains a MyType in its result field. So naturally you'd expect that I could cast the result from an Object to a MyType but the result of doing so is null. Here is some code to illustrate what happens...

private function scenarioLoadedHandler(event:ResultEvent):void {

var result:Object = event.result;

//willCastWork is false

var illCastWork:Boolean = (result is MyType);

//myType is null

var myType:MyType = result as MyType; }

Remember the debugger clearly shows that result is of type "MyType" but the casting fails, any ideas why this may happen?

A: 

Sometimes I experience a similar problem if the browser is loading the cached .swf file. So clear the browser cache and try if this solves your problem.

splash
A: 

This issue sometimes happens when librairies are out of date between applications. I've had the same issue when loading modules inside one another application. When i'd handle communication between the twos, they could not cast objects from one version to another.

tousdan