0

I try to connect blazeDS in actionscript project with the following code:

    ro = new RemoteObject();
    var cs:ChannelSet = new ChannelSet(); 
    cs.addChannel(new AMFChannel("my-amf", "http://localhost:8080/Ninja/messagebroker/amf"));
    ro.channelSet = cs;
    ro.destination = "test"; 
    ro.source = "me.qiankanglai.test";

    ro.addEventListener(ResultEvent.RESULT,r1);
    ro.addEventListener(FaultEvent.FAULT,r2);
    ro.sayHello();

But I cannot connect the server. I make a new flex project and the works well. I use chrome to see the connection detail(Request Payload are different from the very beginning)

The actionscript project: as pro

The flex project:

flex pro

In fact, I got an error from the actionscript project:

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

I don't know what's the differenct between these two ways of remoteobject.

Kanglai
  • 530
  • 1
  • 6
  • 18

2 Answers2

0

I just found the solution in the right part of my question(related questions):

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

I just need one line:

RpcClassAliasInitializer.registerClassAliases();

In this field, stackoverflow is more powerful than Google!

Community
  • 1
  • 1
Kanglai
  • 530
  • 1
  • 6
  • 18
0

I think that you can also use the metadata tag [RemoteClass], but I'm not entirely sure of what you wanna do.

nMoncho
  • 370
  • 2
  • 8
  • Hey, I already tried that but I don't know why it doesn't work. I searched around and some one said that [RemoteClass(alias=...)] worked in flex projects but not in as project. In fact, this metadata tag is "translated" into RpcClassAliasInitializer.xxx from .mxml to .as – Kanglai Apr 06 '12 at 01:09
  • Yeah, I come to know that sometimes the RemoteClass doesnt seem to work, so you have to use RpcClassAliasInitializer.registerClassAliases(); I used to have some problems, but it was related to the Java class hierarchy that I was using. – nMoncho Apr 07 '12 at 14:36
  • This problem troubled me for two days because I got a error for type. :( – Kanglai Apr 08 '12 at 11:28
  • Yes, I got the same error, having an abstract class on top of the Java hierarchy sending the children with the abstract class type (reference) I got that error. My solution was removing the [RemoteClass] tag from the AS3 class peer to the abstract class – nMoncho Apr 10 '12 at 00:10