Welcome to my blog. I mainly blog about the basics of running Flash games over the internet, but sometimes I get distracted. Here you will find my efforts at programming turn based Flash games, plus links to all the games I have written. You are free (as in beer) to get all the code, just email me - nicolas_evans at yahoo.com (sorry you cant click on it - I dont want more spam).
Building Multiplayer Games in Flash.
// in the constructor
for (i = 0;i<15;i++) {
mcCa.attachMovie("McMarker","mcMarker" + i,++gnNextDepth,{_x:-100,_y:-100,_alpha:20});
}
// at the start of turn
k = 0;
i = gnStartI;
j = gnStartJ;
mcCa["mcMarker" + k]._x = (i - 11) * 40;
mcCa["mcMarker" + k]._y = (j - 11) * 40;
do {
if (i < gnEndI)
i++;
else if (i > gnEndI)
i--;
if (j < gnEndJ)
j++;
else if (j > gnEndJ)
j--;
k++;
mcCa["mcMarker" + k]._x = (i - 11) * 40;
mcCa["mcMarker" + k]._y = (j - 11) * 40;
} while ((i != gnEndI || j != gnEndJ) && k < 15)

<?php
$intVariableCount = 7;
$filename = $_GET['filename'];
$action = $_GET['action'];
if (is_numeric($filename)) {}
else
die( "v=v&nErrorNumber=" . $intErrorNumber );
if (file_exists("gamefiles/cr" . $filename . ".txt")) {}
else {
// File does not exist, so create it.
$filePointer = fopen("gamefiles/cr" . $filename . ".txt", "w");
fclose($filePointer);
}
// Check that we have read and write access to the text file.
is_readable("gamefiles/cr" . $filename . ".txt") or die("ERROR : Do not have read access to file $filename, consult your server administrator.");
is_writeable("gamefiles/cr" . $filename . ".txt") or die("ERROR : Do not have write access to file $filename, consult your server administrator.");
// Read the file in
$contents = file("gamefiles/cr" . $filename . ".txt");
$maxid = count($contents);
for ($i = $maxid; $i < $intVariableCount ; $i++) {
$contents[$i] = " ";
}
// Process the actions
// Insert a score/name
if ($action=="INSERT") {
$intErrorNumber = 0;
// Abandon message if not later than the file
$contents[0] = $_GET['pno'];
if ($contents[0] != 1 && $contents[0] != 2) {
$intErrorNumber = 1;
}
if ($contents[1] + 1 != $_GET['nTurn'] ) {
$intErrorNumber = 2;
}
$contents[1] = $_GET['nTurn'];
$contents[2] = $_GET['p1hand'];
$contents[3] = $_GET['p2hand'];
$contents[4] = $_GET['board'];
$contents[5] = $_GET['order'];
$contents[6] = $_GET['ltm'];
if (is_numeric($_GET['messageID'])) {}
else
$intErrorNumber = 8;
if ($intErrorNumber == 0) {
$filePointer = fopen("gamefiles/cr" . $filename . ".txt", "w" );
for ($i=0;$i & lt; $intVariableCount;$i++) {
fwrite($filePointer,"$contents[$i]\n" );
}
fclose($filePointer);
$intTemp = $_GET['messageID'] + 1;
echo "v=v&messageID=" . $intTemp;
}
else {
echo "v=v&nErrorNumber=" . $intErrorNumber;
}
}
// Clear the list
else if ($action=="CLEAR") {
echo "create empty file";
for ($i=0;$i & lt; intVariableCount;$i++) {
$contents[i] = " ";
}
$contents[0] = "2"; // pno
$contents[1] = "0"; // nTurn
$filePointer = fopen( "gamefiles/cr" . $filename . ".txt", "w" );
for ($i=0;$i < $intVariableCount;$i++) {
fwrite($filePointer,"$contents[$i]\n" );
}
fclose($filePointer);
}
else if ($action=="VIEW") {
echo "v=v&nErrorNumber=0" ;
echo "&pno=" . $contents[0] ;
echo "&nTurn=" . $contents[1] ;
echo "&p1hand=" . $contents[2] ;
echo "&p2hand=" . $contents[3] ;
echo "&board=" . $contents[4] ;
echo "&order=" . $contents[5] ;
echo "<m=" . $contents[6] ;
}
else {
echo "action not recognized" . $action;
}
?>

static function fnConvertStringToObjects (pString:String,bProperties:Boolean):Array {
var i:Number;
var arTemp =new Array();
var arTemp2 =new Array();
var arTempOut = new Array();
arTemp = pString.split(",");
for (i =0;i<arTemp.length;i++) {
if (arTemp[i] == "undefined" || arTemp[i] == "")
arTempOut.push("Empty");
else if (!bProperties) {
if (_level0[arTemp[i]])
arTempOut.push(_level0[arTemp[i]] );
}
else { // parse properties (name:nRotation:bLeaky)
arTemp2 = arTemp[i].split(":");
trace (arTemp2)
if (arTemp2[0] == "undefined" || arTemp2[0] == "")
arTempOut.push("Empty");
else if (_level0[arTemp2[0]]) {
arTempOut.push(_level0[arTemp2[0]] );
_level0[arTemp2[0]].nRotation = Number(arTemp2[1]);
_level0[arTemp2[0]].bLeaky = arTemp2[2];
}
}
}
return arTempOut;
}


Play
Fish Or Foul
Play
Mammoths