OK, it's probably easiest now to explain my problem like this, I am able to write the name of my xml file that needs to be loaded to a dynamic textfield on the stage, however, I don't seem to be able to access it after this and strip the necessary data from it, here's my code:
var tf:TextField = new TextField();
tf.autoSize=TextFieldAutoSize.LEFT;
tf.border=true;
addChild(tf);
try {
var keyStr:String;
var valueStr:String;
var paramObj:Object=LoaderInfo(this.root.loaderInfo).parameters;
for (keyStr in paramObj) {
valueStr=String(paramObj[keyStr]);
tf.appendText(valueStr + "\n");
}
} catch (error:Error) {
tf.appendText("error");
}
// load and parse the xml
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest(valueStr));
function LoadXML(e:Event):void {
xmlData=new XML(e.target.data);
xmlData.ignoreWhite = true;
var items:XMLList = xmlData.resource;
var tarray:Array = new Array();
for each (var resource:XML in items) {
tarray.push(resource.@src);
}
c3 = tarray.pop();
c2 = tarray.pop();
c1 = tarray.pop();
Where my xml looks like this, anyone see what I'm doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<xml>
<resource id="thing1" src="swf1.swf" />
<resource id="thing2" src="swf2.swf" />
<resource id="thing3" src="swf3.swf" />
</xml>
Many thanks
// UPDATE
OK, this scenario now works fine, when I directly load the xml:
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("testxml.xml"));
function LoadXML(e:Event):void {
xmlData=new XML(e.target.data);
xmlData.ignoreWhite = true;
var items:XMLList = xmlData.resource;
var tarray:Array = new Array();
for each (var resource:XML in items) {
tarray.push(resource.@src);
}
c3 = tarray.pop();
c2 = tarray.pop();
c1 = tarray.pop();
trace("c1"+c1+"c2"+c2+"c3"+c3); // traces my swf files
Then later, code attached to a button successfully loads the file:
var swf:MovieClip;
var loader:Loader = new Loader();
var defaultSWF:URLRequest = new URLRequest(c1);
So all I want to do now is to be able to achieve the same thing but loading the xml with loadvars as I did before, from my traces it seems there is a scope issue, but I'm not sure why if "c1" can be referenced like it is above..?
thanks