I’m trying to load xml data and then calculate the length of a xml node and then pass that value so that it’s available outside the function.
I’m obviously doing it wrong
also I don’t understand how tlbXML is being passed to the assign() function. does this happen automatically?
package {
import flash.display.MovieClip;
import flash.display.Loader;
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.xml.*;
public class Test extends MovieClip {
public function Test() {
var tlbXML:XML;
var tlbLoader:URLLoader = new URLLoader();
tlbLoader.load(new URLRequest("tlbContent.xml"));
tlbLoader.addEventListener(Event.COMPLETE, processTlbXML);
function processTlbXML(e:Event):void {
tlbXML = new XML(e.target.data);
assign();
}
var tlbNode3Length:int = 0;
function assign(){
var tlbNode3:String = tlbXML.tlb.node3.toString();
tlbNode3Length = tlbNode3.length;
getValue(tlbNode3Length)
}
function getValue(tlbNode3Length){
//this trace obvoiusly works
trace(tlbNode3Length + " = tlbNode3Length inside function ");
return tlbNode3Length;
}
//trying to pass the value of tlbNode3Length to var valueIGet
var valueIGet:int = getValue(tlbNode3Length);
trace(valueIGet + " = tlbNode3Length outside function ");
}
}
}
help is much appreciated thanks in advance.