i am experimenting on making a multiplayer game using smartfoxserver pro, but i have a problem,
when i click on the "connect" button (you need to put in "localhost" or "127.0.0.1" on the ip box), it cannot connect and gives me the following error:
** Socket connection failed. Trying BlueBox **
import it.gotoandplay.smartfoxserver.*
/*#include "lib/[flashAPI].as"
#include "lib/easingEquations.as"
#include "lib/easing.as"*/
/*
* ----------------------------------------------------------------------------
* [ Avatar Chat ] version 1.1.0 -- Actionscript 2.0
* a SmartFoxServer sample application
*
* (c) 2004 gotoAndPlay()
* ----------------------------------------------------------------------------
*/
stop()
Stage.showMenu = false
//----------------------------------------------------------
// Setup global variables
//----------------------------------------------------------
var stageW:Number = 780
var stageH:Number = 490
// hide semi-transparent panel
// used when a dialog box is shown
// isBusy is true when the application
// is requiring input through a dialog box
// When true all other controls are temporarily disabled
_global.isBusy = false
// An event queue
var evtQueue:Array = []
//----------------------------------------------------------
// Setup global variables
//----------------------------------------------------------
showLogin(false)
var smartfox:SmartFoxClient = new SmartFoxClient()
//----------------------------------------------------------
// Server configuration
//
// ip = IP address of the server, if the server is running
// locally use 127.0.0.1
// port = default value is 9339
// zone = the Server "zone" name for this application
//----------------------------------------------------------
var port:Number = 9339
var zone:String = "simpleChat"
_root.butt_check.onRelease = function() {
var ip:String = _root.ip_txt.text;
trace(_root.ip_txt.text);
status_txt.text = "Connecting..."
smartfox.onConnection = handleConnection
smartfox.debug = true
// Connect to the server
smartfox.connect(ip, port);
}
//----------------------------------------------------------
// Handle connection response from server
//----------------------------------------------------------
function handleConnection(success:Boolean)
{
if (success)
{
status_txt.text = "Connected, please login:"
showLogin(true)
butt_login.onRelease = sendLogin
}
else
{
status_txt.text = "Can't connect!"
}
}
//----------------------------------------------------------
// Send login params to the server
// server.login(zone, nickName, password)
//----------------------------------------------------------
function sendLogin()
{
if (!_global.isBusy)
smartfox.login(zone, login_txt.text, null)
}
//----------------------------------------------------------
// Handle login response from server
//----------------------------------------------------------
smartfox.onLogin = function(resObj:Object)
{
if (resObj.success)
{
// Login Succesfull
_global.myName = resObj.name
}
else
{
// Login Failed
_gloabl.isBusy = true
// Show an error window
var win:MovieClip = showWindow("errorWindow")
win.errorMsg.text = resObj.error
}
}
//----------------------------------------------------------
// Handle the onRoomListUpdate here and keep it in the
// queue. We'll handle it in the next frame.
//----------------------------------------------------------
smartfox.onRoomListUpdate = function(o:Object)
{
evtQueue.push(o)
gotoAndStop("chat")
}
//----------------------------------------------------------
// Handle unexpected server disconnection
//----------------------------------------------------------
smartfox.onConnectionLost = function()
{
gotoAndStop("connect")
}
//----------------------------------------------------------
// Show / Hides the login input field and submit button
//----------------------------------------------------------
function showLogin(bool:Boolean)
{
//butt_login._visible = bool
//login_txt._visible = bool
//loginBox._visible = bool
if (bool)
Selection.setFocus("login_txt")
}
//----------------------------------------------------------
// Shows a popup window and disables all other controls
//----------------------------------------------------------
function showWindow(linkageName:String):MovieClip
{
_global.isBusy = true
disabler._visible = true
roomList_lb.setEnabled(false)
userList_lb.setEnabled(false)
var win = _root.attachMovie(linkageName, linkageName, 9999)
win._x = (stageW / 2) - (win._width / 2)
win._y = (stageH / 2) - (win._height / 2)
return win
}
//----------------------------------------------------------
// Hides a popup window and re-enable the controls
//----------------------------------------------------------
function hideWindow(wName:String)
{
this[wName].removeMovieClip()
roomList_lb.setEnabled(true)
userList_lb.setEnabled(true)
disabler._visible = false
_global.isBusy = false
}