login without loginbox help

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

Moderators: Lapo, Bax

User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 20 Mar 2009, 10:10

kenjii, I suppose you have to study Flash and ActionScript 2 a little more. The issues you are having are not related to SmartFoxBits or SmartFoxServer, but to generic ActionScript coding.

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")
}
Paolo Bax
The SmartFoxServer Team
kenjii
Posts: 27
Joined: 06 Mar 2009, 12:33
Location: france

Postby kenjii » 20 Mar 2009, 10:17

yes i need to study flash more and more like smartfox server too :)

if i do that i have the api error egain from the :

var smartFox:SmartFoxClient = connector_mc.connection .

I will search for it thank's a lot for the time you give me
kenjii
Posts: 27
Joined: 06 Mar 2009, 12:33
Location: france

Postby kenjii » 20 Mar 2009, 11:27

i have finaly found my problem !!!

it work when i use code from yathzee file tutorial .

here is the code i use

Code: Select all

#include "SmartFoxClient.as"

stop()
_global.isBusy = false

ip       = "127.0.0.1"
port    = 9339
zone    = "yahtzee"


connector_mc = new SmartFoxClient()
connector_mc.onConnection = handleConnection
connector_mc.connect(ip, port)

function handleConnection(success)
{
   if (success)
   {
      status_txt.text = "Connected, please choose a username:"
      
      butt_login.onRelease = sendLogin
   }
   else
   {
      status_txt.text = "Can't connect!"
   }
}

var zone = "sftris"
var login = " mano"
function sendLogin()
{
   if (!_global.isBusy)
      connector_mc.login(zone, login, null)
           gotoAndStop("chat")
}
connector_mc.onLogin = function(resObj)
{
   if (resObj.success)
   {
      // Login Succesfull
      _global.myName = resObj.name
      status_txt.text = "login ok!" + _global.myName
   }
   else
   {
      status_txt.text = "Can't login!"
   }
}


In fact if i use this

import it.gotoandplay.smartfoxserver.*
it don't work ...

Thank's a lot bax
neo1011
Posts: 1
Joined: 31 Jul 2010, 13:11

login

Postby neo1011 » 31 Jul 2010, 13:16

Code: Select all

var smartFox:SmartFoxClient=connector.connection;
// Register for onRoomListUpdate event in order to go to the "chat" screen
// when the list of available rooms is received.
// The RoomList component will take care of joining a room.
smartFox.addEventListener( SFSEvent.onRoomListUpdate, onRoomListUpdate )
smartFox.addEventListener( SFSEvent.onConnectionLost, onConnectionLost )
smartFox.addEventListener(SFSEvent.onConnection, onConnectionHandler);
smartFox.addEventListener(SFSEvent.onLogin, onLogin);

//
function onConnectionHandler(evt:SFSEvent):void {

   if (evt.params.success) {
      trace("Great, successfully connected!");
      smartFox.login("mazeGame", "ssdd", null);
   }
}
//
function onLogin(evt:SFSEvent):void {

   var ok:Boolean=evt.params.success;
   if (! ok) {
      trace("login :"+evt.params.error);
   }
   //   var response:Object = evt.params.resObj
   //   
   //   if (response.success)
   //      gotoAndStop("chat")
}



function onRoomListUpdate( evt:SFSEvent ):void {
   gotoAndStop( "chat" );
}

//----------------------------------------------------------
// Handle unexpected server disconnection
//----------------------------------------------------------
function onConnectionLost( evt:SFSEvent ):void {
   gotoAndStop( "connect" );
}

Return to “SmartFoxBits for SFS 1.x”

Who is online

Users browsing this forum: No registered users and 2 guests