Page 1 of 1

Confusing Problem :/

Posted: 17 Jan 2008, 16:40
by Prof_PP
I am using SFS 1.6 with Bits 1.1. I have imported and installed the AS2 libs.

However, I cannot appear to get the smartfox functions to work all the time. In fact they only worked sometimes. For example:

Code: Select all

import it.gotoandplay.smartfoxbits.events.*
import it.gotoandplay.smartfoxserver.*
import mx.utils.Delegate

stop()
var smartFox:SmartFoxClient = new SmartFoxClient();

function onlogout_btClick():Void
{
	smartFox.onLogout = onLogoutHandler
	smartFox.logout()
	gotoAndStop("Connect")
}

function onLogoutHandler():Void
{
    trace("Logged out successfully")
}
Nothing is traced and the logout has not executed because I cannot log on again. Yes, it is a multiframe application and I know this causes issues, but I am really confused with this.

Is there a conflict with using SFBits?

Any suggestions from anyone would be appreciated.

Regards
Paul.

Posted: 18 Jan 2008, 14:14
by Bax
From the code you posted, it seems you are using the SmartFoxClient class in a wrong way.
In fact, when you use SmartFoxBits, the Connector is in charge of instantiating the SmartFoxClient class, and you should take a reference to it by means of this property:

Code: Select all

var smartFox:SmartFoxClient = connector_mc.connection
where connector_mc is the Connector's instance name (check this link for more details).

With SmartFoxBits, also registering to SmartFoxServer events is a little different: in fact you must comply to the Connector's event handling system.
If you register to the onLogout event like this:

Code: Select all

smartFox.onLogout = onLogoutHandler
you are overwriting the same event listener that the Connector creates internally.
The right way to register to SmartFoxServer events when using SmartFoxBits is through the Connector:

Code: Select all

connector_mc.addEventListener(SFSEvent.onLogout, onLogoutHandler)
Check this link for more details.

Hope this helps.

Posted: 19 Jan 2008, 17:56
by Prof_PP
Thanks Bax

Appreciate the help. I knew it was something I was doing or not doing. Looks like this will solve a few other issues I was working on.

Thanks and regards
Paul.