var s : String; // string containing XML
var h : String; // string to create a hexadecimal value for colours
var i : int;
// create xml as a string
s = '<balllist>\n';
for (i = 0; i < b.length; i++) {
s = s + "\t<ball>\n";
s = s + "\t\t<id>" + i + "</id>\n";
s = s + "\t\t<x>" + b[i].x + "</x>\n";
s = s + "\t\t<y>" + b[i].y + "</y>\n";
h = b[i].c.toString(16);
while (h.length < 6) {
h = "0" + h;
}
s = s + "\t\t<c>0x" + h + "</c>\n";
s = s + "\t\t<m>" + b[i].m + "</m>\n";
s = s + "\t</ball>\n";
}
s = s + "</balllist>";
// pass string to php routine which saves the data, using POST method
var req : URLRequest = new URLRequest();
var loader : URLLoader = new URLLoader();
req.data = s;
req.contentType = "text/xml";
req.method = URLRequestMethod.POST;
req.url = "SaveXML.php";
loader.load(req);