2

I am new to ActionScript 3. I am attempting to call the server from the client using the nc.call() method to see if this was a good option to use for clients to communicate back and forth in a chat application.

I received a compile error message:

1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.net:Responder.

Can somebody please help me fix this error?

This is my client-side code below:

 import flash.net.NetConnection;
 import flash.events.NetStatusEvent;

 var nc:NetConnection = new NetConnection();

 nc.connect("rtmfp:/fms/textchatexample");

 nc.addEventListener(NetStatusEvent.NET_STATUS, netHandler);

 function netHandler(event:NetStatusEvent):void {
     switch(event.info.code) {
         case "NetConnection.Connect.Success":
             trace("Your Connected UP");
             break;
     }
 }

 var test:Object = new Object();
 test.onResult = function(arg) {
     trace(arg);
 };
 nc.call("sendMsg", test, "just, a test call"); ERROR LINE
duTr
  • 714
  • 5
  • 21
Mark Noble
  • 21
  • 2
  • You should add the event listener on your `NetConnection` before you call the `connect()` method. Then you should not attempt to call `nc.call()` before the connection has been established with the server, i.e before your receive a `NetStatusEvent` with with a code `NetConnection.Connect.Success` – duTr Mar 28 '13 at 05:07

1 Answers1

0

try to replace your Object instance with a Responder:

var test:Responder = new Responder(
    function(result):void
    {
        trace('ok :', result);
    },
    function(status):void
    {
        trace('status :', status);
    });

instead of your Object

duTr
  • 714
  • 5
  • 21
www0z0k
  • 4,444
  • 3
  • 27
  • 32
  • Thanks for your reply www0z0k. I did has you suggested but it appears its still not working. I am receiving nothing in my FMS administration console. You have seen my client side code. This is my Server-Side can you plz take a close look to see if you can identify any errors: application.onConnect = function(client){ //accept client this.acceptConnection(client); client.sendMsg = function(msg); trace"sendMsg", "just a test"); return msg; – Mark Noble Feb 25 '13 at 13:55
  • Have a look [here](http://stackoverflow.com/questions/14140864/sharedobjecst-send-method) for your connection problem – duTr Mar 28 '13 at 09:59