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

I recently ported code from a Flex project to a new clean AS3 project. When I tried to make an AMF call, I get an error message as follows:

TypeError: Error # 1034: Type Coercion error: 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 kinds of things (checking that all the necessary libraries from the flex framework are included, etc.), but nothing worked.

+4
source share
2 answers

After a while, I found the answer: Flex does some initialization at startup, with which the AMF classes will not work. Luckily, Adobe thought of those who wanted to use AMF from a non-flex project or from flash memory, and provided a method for performing the initialization required by AMF.

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

RpcClassAliasInitializer.registerClassAliases ();

(Yes, I answered my question. I did not find any blogs or search results on this issue, so I share this issue and fix it here.)

+7
source

I know this is a little late, but you could not use flash.net.registerClassAlias? It seems that RpcClassAliasInitializer is part of the mx.utils package , which is still part of the Flex library.

0
source

Source: https://habr.com/ru/post/1392680/


All Articles