views:

97

answers:

1

I've created a custom class to handle method calls from the server and I get this error

Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback close. error=ReferenceError: Error #1069: Property close not found on MyClient and there is no default value.

code from function that does the connection:

    myClient = new MyClient();
    myClient.addEventListener(HearEvent.HEARD_SOMETHING,onHear);

    nc = new NetConnection();           
    nc.addEventListener(NetStatusEvent.NET_STATUS, ncOnStatus);
    nc.client = dasClient;          
    nc.connect(connectStr.text, p1.text, p2.text, int(p3.text), p4.text);

that's the MyClient class

public class MyClient extends EventDispatcher
{   
    public function hear(s:String):void
    {
        trace(s);
        dispatchEvent(new HearEvent(s, HearEvent.HEARD_SOMETHING));
    }
}
+1  A: 

Depending on your requirements, you can either ignore this error by handling the AsyncErrorEvent in an empty function or prevent the error from happening by adding a close method to the MyClient that performs appropriate action.

Amarghosh
could you tell me what parameters should the close function have ?
Omu
`close()` method of `NetStream` class doesn't take any arguments. Try that and see if it works.
Amarghosh
:) it works, it looks like it was an unsuccessful connection and the close method was being invoked to close the connection, but since the close is in my custom client, the connection isn't being closed anymore, I thinking that probably it is better to just extend the NetConnection class, how do you think ?
Omu
That seems to be the better choice. Just assign `client = this` and you're good to go. (I guess you would still need to assign onMetadata, onCuepoint etc).
Amarghosh