Page 1 of 1

Connector needs to have server IP & port set directly

Posted: 01 Apr 2011, 06:30
by jonc
Hi,

I'm a bit confused about the Connector control and config info.

I see there is a Connector.configPath member. I tried setting this to the config file and then calling connect(), but that fails.

It seems that I instead have to call sfs.LoadConfig() and then get the config data and stuff it into the Connector component before calling connect().

Code: Select all


public function onSFSConfigLoadSuccess( event:SFSEvent ) : void
{
    var config:ConfigData = sfs.config;
    connector.serverIpAddress = config.host;
    connector.serverPort = config.port;
    connector.connect();
}


Although this works, it makes me wonder what the point of the Connector.configPath member is. Is that only used if you are creating the component through MXML? The documentation isn't very clear on this point.

Posted: 01 Apr 2011, 08:02
by Bax
Setting the Connector.configPath property should be enough, causing the Connector to load the external xml file.
I'm not sure if we tested this specifically when you instantiate the Connector using AS3 instead of MXML. It might be a bug.
Can you show the code used to create the Connector?

Posted: 01 Apr 2011, 08:10
by jonc
Here's an example of code that doesn't work (we get a connection failed event):

Code: Select all


connector = new Connector();
connector.configPath = "sfs-config.xml";
connector.connect();



The same config file works if we load it through sfs.loadConfig() and then set the connector IP address and port directly as in the code I posted above.

Posted: 01 Apr 2011, 08:46
by Bax
Why version of the Bits do you use? Flash or Flex?

Posted: 01 Apr 2011, 08:56
by jonc
Flex.

Posted: 01 Apr 2011, 09:04
by Bax
Figured out.
The Connector relies on the cretionComplete Flex event. When this event is fired, it checks if the configPath property was set and loads the external file.

When you create the Connector using AS3 instead of MXML, the cretionComplete event is fired before you set the configPath, so it is not able to "see" the value you pass anymore.
You have to set the connection details manually.

Posted: 01 Apr 2011, 09:07
by jonc
Makes sense. Thanks for looking into it Paolo.