Hello,

I am sorry if this is in the wrong spot. But, I'm having troubles with creating a multiplayer flash game. The concept is very simple, and really all I need is to track players clicking on squares (via a mysql database) and make sure all players are seeing the same thing on the screen. However, the execution has been much more challenging.

I have looked at SmartFox, Player.IO, Node.js, and so far I don't understand or like them at all. I'd really like to use a php5 socket server, since that is supported on the web host that I'm using. Now I know there has been a lot of back and forth about whether a php socket server is good or bad, but since this particular game is rather simple, I'd like to at least give it a shot.

All of the tutorials or anything else I have tried is either in AS2 and I have to translate it, or its very old and I can't make heads or tails out of it. I did code one, but for some reason it refused to run. It would run in the IDE, but when I tried to run the .swf it wouldn't even connect. If someone could point me to a good tutorial for a php-flash integration, I would appreciate it. Or if you want to look at the code for the flash file I did and point out if I did something wrong that is causing it to not even load in the .swf, that would be appreciated too. I am not a very experienced AS3 or PhP programmer, however I have a lot more experience in AS3 than php so a lot of these concepts are rather new to me.

Thank you very much for your time.

Code:
import flash.net.*;
import fl.controls.*;
import flash.events.MouseEvent;
import flash.events.DataEvent;
import flash.events.SecurityErrorEvent;

var mySocket = new XMLSocket();
pushMsg.addEventListener(MouseEvent.CLICK, realsedButton);
mySocket.connect("localhost",9999);
mySocket.addEventListener(Event.CONNECT, xmlsocket);
mySocket.addEventListener(Event.CLOSE, xmlsocket);
mySocket.addEventListener(IOErrorEvent.IO_ERROR, xmlsocket);
mySocket.addEventListener(DataEvent.DATA, dataHandler);
mySocket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityHandler);   

msgArea.htmlText = "Started!";

function securityHandler(evt: SecurityErrorEvent)
{
	msgArea.htmlText = "SecurityError";
}

function dataHandler(evt:DataEvent)
{
	trace("Inside dataHandler")
	var xml = XML(evt.target.data);
	msgArea.htmlText += xml;
}


function xmlsocket(Event)
{
	msgArea.htmlText += "inside xmlSocket";
	switch(Event.type)
	{
		case 'ioError':
			msgArea.htmlText += "Inside dataHandler";
			msgArea.htmlText += "<b>Server connection failed!</b>";
			break;
		
		case 'connect':
			msgArea.htmlText +="Inside Connect";
			msgArea.htmlText += "<b>Server connection establed!</b>";
			break;
			
		case 'close':
			msgArea.htmlText +="Inside Close";
			msgArea.htmlText += "<b>Server connection lost</b>";
			break;
	}
}

function msgGO() 
{
	msgArea.htmlText +="Inside msgGO";
	if (inputMsg.htmlText != "") 
	{
		msgArea.htmlText +="Inside msgGo2";
		mySocket.send(inputMsg.htmlText+"\n");
		inputMsg.htmlText = "";
	}
}

function realsedButton(evt:MouseEvent)
{
	msgArea.htmlText +="Inside ReleasedButton";
	msgGO();
}
This is all timeline code. The "Inside <blah>" messages are just for debugging, since I'm having issues to get it to run.
If I run it from Flash CS 5 IDE, (Ctrl+Enter) I get the Messages Started! , inside xmlSocket, Inside dataHandler, Server connection failed!
If I run it from a published .swf or .html, I get nothing. Not even the Started!