Confusing Problem :/

Everything about the SmartFoxBits UI Components for SmartFoxServer 1.x. Post your questions, suggestions and bug reports.

Moderators: Lapo, Bax

Post Reply
User avatar
Prof_PP
Posts: 126
Joined: 07 Dec 2007, 08:53
Location: Austria
Contact:

Confusing Problem :/

Post 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.
_________________________________

Dr. Paul Pivec, PhD, MComp, GDipHe
CranberryBlue R & D Ltd.
http://www.piveclabs.com
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post 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.
Paolo Bax
The SmartFoxServer Team
User avatar
Prof_PP
Posts: 126
Joined: 07 Dec 2007, 08:53
Location: Austria
Contact:

Post 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.
_________________________________

Dr. Paul Pivec, PhD, MComp, GDipHe
CranberryBlue R & D Ltd.
http://www.piveclabs.com
Post Reply