CFC 和 Flex 之间的嵌套类强制转换失败
我有两个 AS3 类,A 和 B。A 类包含一个 ArrayCollection,它将保存 B 类的多个实例。
在 ColdFusion 中,我有匹配的 CFC,具有相同顺序的同名变量,以及每个变量的 cfproperty 标记。
AS3 类都使用 RemoteClass 元数据将它们与其 CFC 对应项关联起来。
问题是,虽然 A.cfc 从 CF 返回并适当地填充 A.as 实例,但我无法填充任何嵌套的 B.as 实例。 相反,我收到此错误:
TypeError: Error #1034: Type Coercion failed: cannot convert []@2f4465f1 to mx.collections.ArrayCollection.
为什么 A 实例除了其嵌套 B 实例的集合之外还能正常工作?
I have two AS3 classes, A and B. Class A contains an ArrayCollection that will hold multiple instances of class B.
In ColdFusion, I have matching CFCs, with same-named variables in the same order, as well as cfproperty tags for each variable.
The AS3 classes both use the RemoteClass metadata to associate them with their CFC counterparts.
The problem is that, while A.cfc comes back from CF and populates the A.as instances appropriately, I can't get any of the nested B.as instances to populate. Instead, I get this error:
TypeError: Error #1034: Type Coercion failed: cannot convert []@2f4465f1 to mx.collections.ArrayCollection.
Why would the A instance work fine except for the collection of its nested B instances?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是该对象作为数组从 ColdFusion 返回,而 Flex 不想为我将其转换为 ArrayCollection。 Flex 会将 ColdFusion 查询转换为 ArrayCollection,但 ColdFusion 数组显然只能是 Flex 中的数组(自动)。
我将 Flex 中的 ArrayCollection 更改为 Array,一切正常。
The problem was that the object was coming back from ColdFusion as an array and Flex didn't want to convert that into an ArrayCollection for me. Flex will turn a ColdFusion query into an ArrayCollection, but a ColdFusion array apparently can only be an Array (automatically) in Flex.
I changed the ArrayCollection in Flex to an Array and everything works fine.