This is the right way to go:
Code: Select all
import it.gotoandplay.smartfoxserver.*
import it.gotoandplay.smartfoxbits.events.*
stop()
var zone:String = "simpleChat"
var myUserName:String = "Jack"
var smartFox:SmartFoxClient = connector_mc.connection
connector_mc.addEventListener(SFSEvent.onConnection, onConnectionHandler)
connector_mc.addEventListener(SFSEvent.onLogin, Delegate.create(this, onLogin))
function onConnectionHandler(evt:SFSEvent):Void
{
if (evt.params.success)
{
trace("Great, successfully connected!")
// Log into the "simpleChat" zone without using the LoginBox component
smartFox.login(zone, myUserName)
}
}
function onLogin(evt:SFSEvent):Void
{
var response:Object = evt.params.resObj
if (response.success)
gotoAndStop("chat")
}