I have a php file which outputs an XML data and i also have a swf file coded with AS3 where i want to load the ouput of PHP in.
PHP Code:
echo "<root>
<Username>" . $xml1 . "</Username>
<XMLNode2>" . $xml2 . "</XMLNode2>
<XMLNode3>" . $xml3 . "</XMLNode3>
</root>";
AS3 Code:
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.xml.XMLDocument;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoaded);
loader.load(new URLRequest("playerData.php"));
var variables:URLVariables = new URLVariables();
function onLoaded(evt:Event):void
{
var xDoc:XMLDocument = new XMLDocument();
xDoc.ignoreWhite = true;
loader.resultFormat = "e4x";
var myXML:XML = loader.data as XML;
xDoc.parseXML(myXML.toString());
user_name.text = trace(xDoc.Username);
}
This is the error i get in AS3 code:
Access of possibly undefined property Username through a reference with static type flash.xml:XMLDocument.
Basically those TxtElements are dinamic text (like labels).