使用来自 Flash 或纯 AS3 项目的 RemoteObject (AMF) [英] Using RemoteObject (AMF) from a Flash or Pure AS3 Project

查看:20
本文介绍了使用来自 Flash 或纯 AS3 项目的 RemoteObject (AMF)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将 Flex 项目中的一些代码移植到新的纯 AS3 项目中.当我尝试拨打 AMF 电话时,收到如下错误消息:

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:错误 #1034:类型强制失败:无法将 Object@5425371 转换为 mx.messaging.messages.ErrorMessage.

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.

我尝试了各种方法(检查是否包含了 flex 框架中所有必需的库等),但没有任何效果.

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

推荐答案

一段时间后,我找到了答案:Flex 在启动时做了一些初始化,如果没有,AMF 类将无法运行.幸运的是,Adobe 已经想到了那些想要从非 flex 项目或 Flash 中使用 AMF 的人,并提供了一种方法来进行 AMF 所需的初始化.

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.

我将这一行添加到我的应用程序的开头,突然所有 AMF 调用都像在我的 Flex 项目中一样工作:

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();

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.)

这篇关于使用来自 Flash 或纯 AS3 项目的 RemoteObject (AMF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆