Using RemoteObject (AMF) from a Flash or Pure AS3 Project

こ雲淡風輕ζ 提交于 2020-01-14 13:40:48

问题


I recently ported some code from a Flex project over to a new pure AS3 project. When i attempted to make an AMF call, I am getting an error message like this:

TypeError: Error #1034: Type Coercion failed: cannot convert Object@5425371 to mx.messaging.messages.ErrorMessage.

There was no stack trace associated with the error, so debugging was difficult.

I tried all manner of things (checking that all required libraries from the flex framework were included, etc) but nothing worked.


回答1:


After some time i found the answer: Flex does some initialization on startup which the AMF classes will not function without. Luckily Adobe has thought of those who want to use AMF from a non-flex project, or from flash, and have provided a method for doing the initialization required by AMF.

I added this line to the start of my application, and suddenly all AMF calls worked as well as they did in my Flex project:

RpcClassAliasInitializer.registerClassAliases();

(Yeah, i answered my own question. I didn't find any blogs or search results for this problem, so i'm sharing the problem and fix here.)




回答2:


I know this is a bit late of a response, but couldn't you have also used flash.net.registerClassAlias? Seems like RpcClassAliasInitializer is part of the mx.utils package which is still part of the Flex library.



来源:https://stackoverflow.com/questions/8987109/using-remoteobject-amf-from-a-flash-or-pure-as3-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!