开发者

Flex can't cast an Object to MyType despite the debugger indicating the object is MyType

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 O开发者_开发知识库bject. 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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜