Friday, September 9, 2011

work arround for: “ArgumentError: Error #2082: Connect failed because the object is already connected” in Flex, Air


This error can occur for three reasons:
1) The string value passed to the connection Name parameter was null.
Pass a non-null value.
2) The value passed to the connection Name parameter contained a colon
(:). Colons are used as special characters to separate the superdomain
from the connectionName string in the send() method, not the
connect()method.
3) The LocalConnection instance is already connected.
Following solution is for 3)
idea: For every exception thrown for reconnect create a nw connection.

/*while initializing the connection call connect() method,, and use variable "connectionName" while invoking methods as: localConnection.send(_connectionName,"methodName");*/
private var _connectionName:String = “swf2AIR”;
private function connect():void {
   try {
       fromAIR.connect(_connectionName);
   }
   catch(e:*) {
      _connectionName = _connectionName+”1″;;
   connect();
  }
}

No comments:

Post a Comment