Im trying to make a Flash toy for my family where I create an montage image using MCs and place the swf on a website. The swf could then be altered / added to by the recipient and returned.
So I figured I could use XML to hold the names of the MCs and write that to the server using PHP. I know a little about XML but even less about PHP. There is a nice, simple example in “Learning Actionscript 3.0” by Shupe and Rosser.
I cannot make it work.
I get Error #1088: The markup in the document following the root element must be well-formed.
I have validated the xml in Dreamweaver.
I have ensured the domain name is correct.
The swf and PHP files are in the same folder on the web server
I have tried using relative and absolute path names.
I dont think it is the XML or the scripts. My suspicion lies with the PHP settings on the web server where I am completely out of my depth.
I would appreciate some guidance.
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.text.TextField;
public class SendingXML extends Sprite {
public var respTxt:TextField;
public function SendingXML() {
var xmlString:String = "<?xml version='1.0' encoding='ISO-8859-1'?><root><value>1</value></root>"
var book:XML = new XML(xmlString);
var xmlURLReq:URLRequest = new URLRequest("http://www.YOURDOMAIN.com/savexml.php");
xmlURLReq.data = book;
xmlURLReq.contentType = "text/xml";
xmlURLReq.method = URLRequestMethod.POST;
var xmlSendLoad:URLLoader = new URLLoader();
xmlSendLoad.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
xmlSendLoad.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
xmlSendLoad.load(xmlURLReq);
}
private function onComplete(evt:Event):void {
try {
var xmlResponse = new XML(evt.target.data);
respTxt.text = xmlResponse;
removeEventListener(Event.COMPLETE, onComplete);
removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
} catch (err:TypeError) {
respTxt.text = "An error occured when communicating with server:
" + err.message;
}
}
private function onIOError(evt:IOErrorEvent):void {
respTxt.text = "An error occurred when attempting to load the XML.
" + evt.text;
}
}
}
<?php
if (isset($GLOBALS["HTTP_RAW_POST_DATA"])){
$xml = xmldoc($GLOBALS["HTTP_RAW_POST_DATA"]);
$file = fopen("data.txt","wb");
fwrite($file, $data);
fclose($file);
if (!$file) {
echo("<root><status>PHP write error. Check permissions.</status></root>");
}else{
echo("<status>File saved.</status>");
}
}
?>
EDIT ---------------
I created a new folder below root on my website and set permissions on that to 765.
I now get a different error:
Error #2032: Stream Error.
Is that a step forward?