AS3 onLogin Event Failing

You think you've found a bug? Please report it here.

Moderators: Lapo, Bax

Post Reply
HariBabu
Posts: 8
Joined: 05 Mar 2008, 05:45

AS3 onLogin Event Failing

Post by HariBabu »

Sir,
I am Using AS 3 version in a project of Chat Room Development.I am Going in a step by step way by each Frame.
In the First frame I am Using the code
<code>
var smartFox:SmartFoxClient = new SmartFoxClient(true)
smartFox.addEventListener(SFSEvent.onConnection, onSFSConnection)
onSFSRoomListUpdate)
function onSFSConnection(evt:SFSEvent):void
{
trace("\nHHHHHHH\nBefore condition Point\nConnection succesful:", evt.params.success+"\nHHHHHHH\n")

if (evt.params.success){
smartFox.defaultZone="simpleChat";
smartFox.login(smartFox.defaultZone, myUsername, "")
mcp_Connect.txt_ConnectMSG.autoSize="left";
mcp_Connect.txt_ConnectMSG.text="Connection Successfull...!";
this.gotoAndPlay(2);
}else{
mcp_Connect.txt_ConnectMSG.autoSize="left";
mcp_Connect.txt_ConnectMSG.text="Connection is not established...!";
this.gotoAndStop(2);
}
trace("\nHHHHHHH\nAfter condition Point\nConnection succesful:", evt.params.success+"\nHHHHHHH\n")
}


smartFox.loadConfig("config/sfsClient.xml", true)
</code>
This is successfull., but in the Next Frame I designed a Form to enter name and Password. But,when I am Using the
<code>
smartFox.addEventListener(SFSEvent.onLogin, onSFSLogin)

function onSFSLogin(evt:SFSEvent):void
{
trace("Login succesful "+evt.params.success);
if (evt.params.success){
// myUsername = evt.params.name
trace("Login successfull with : "+evt.params.name);
this.gotoAndStop("JoinRoom");
}else{
trace(smartFox.myUserId+"\n"+smartFox.myUserName+"\nZone login error; the following error occurred: " + evt.params.error);
mcp_loginError.txt_LoginError.autoSize="left";
mcp_loginError.txt_LoginError.text=evt.params.error;
mcp_loginError.visible=true;
// fm.setFocus(txt_Login.text);
var fm1:FocusManager = new FocusManager(this);
fm1.setFocus(txt_Login);
}
}
btn_Submit.addEventListener(MouseEvent.CLICK, onLoginSubnitBtClick)

function onLoginSubnitBtClick(evt:MouseEvent):void
{
var arr_ERROR_MESSAGES:Array=new Array();
var arr_ERROR_FIELDS:Array=new Array();

// trace("Event "+evt.type);
if(txt_Login.text==""){
arr_ERROR_MESSAGES[arr_ERROR_MESSAGES.length]="Please enter Login Name.";
arr_ERROR_FIELDS[arr_ERROR_FIELDS.length]=txt_Login;
}
if(txt_Pwrd.text==""){
arr_ERROR_MESSAGES[arr_ERROR_MESSAGES.length]="Please enter User Password.";
arr_ERROR_FIELDS[arr_ERROR_FIELDS.length]=txt_Pwrd;
}
if(arr_ERROR_MESSAGES.length>0){
mcp_loginError.txt_LoginError.autoSize="left";
mcp_loginError.txt_LoginError.text=arr_ERROR_MESSAGES[0];
mcp_loginError.visible=true;
fm.setFocus(arr_ERROR_FIELDS[0]);
}else{
mcp_loginError.txt_LoginError.text="";
mcp_loginError.visible=false;
smartFox.defaultZone="simpleChat";
smartFox.login(smartFox.defaultZone, txt_Login.text, txt_Pwrd.text)
}
}
</code>
Smartfox is not allowing the new User, which has the name and Password from mY Login Form.
It is tracing the below Error :
<error>
Login succesful false
20
null
Zone login error; the following error occurred: User already logged in
</error>
from the Debug Window of Tracing action, I found that a user with unknown name and a numeric ID 20 was automatically Logged in.But what about my User to Join as Next User. Why The Srver is messaging
: User already logged in the Connection successfull Event
<TRACE>
HHHHHHH
Before condition Point
Connection succesful: true
HHHHHHH

[Sending]: <msg t='sys'><body action='login' r='0'><login z='simpleChat'><nick><![CDATA[null]]></nick><pword><![CDATA[]]></pword></login></body></msg>


HHHHHHH
After condition Point
Connection succesful: true
HHHHHHH

</TRACE>.
<observed>
While I am testing the Advanced TheoChat Example also, I found one Peculiar thing. There also I can only see My Logged in avathar.Not all the Logged avathars.How a multi user Chat can show only one User?
</observed>
<problem>
FOR my current Project, how could I proceed on to make my End users freely Logged in?
</problem>
Post Reply