4
votes

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.

2
So its a pure AS3 project including the required Flex libraries? You're confusing me.RIAstar
Can you include some of your code? Also, which method of setting up the AMF are you using? If you're getting an mx package error message, but not using Flex, that might be an issue.James Tomasino
You should remove the edit in your question and submit an actual answer, so it will no longer be considered open and unanswered.weltraumpirat
I would love to, but stack overflow says I must wait 8 hours after submitting my question before i can do that :/user963395
Now there's a new entry to you todo-list ;) Your info is quite useful, by the way - I was just trying to find a way to solve this...weltraumpirat

2 Answers

7
votes

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

0
votes

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.