Ok so i’m trying to create a percentage bar that automaticlly adjust depending on data pulled from a XML file. and I’m currently have some problems with the data getting to the second frame… here is what I have
the xml file code:
<?xml version="1.0" encoding="utf-8"?>
<myxml>
<?processing instructions?>
<date>03.23.09</date>
<peep1>
<market>PDS</market>
<consumer>
<goal>9700</goal>
<stretch>1815</stretch>
<actual>1000</actual>
</consumer>
<business>
<goal>1416</goal>
<stretch>1815</stretch>
<actual>100</actual>
</business>
</peep1>
</myxml>
the frame1 actionscript 3.0 code:
XML.ignoreComments=false;
XML.ignoreProcessingInstructions=false;
var my_xml:XML;
var xmlReq:URLRequest=new URLRequest("my.xml");
var xmlLoader:URLLoader = new URLLoader();
function xmlLoaded(event:Event):void {
my_xml=new XML(xmlLoader.data);
info_txt.text=my_xml.toXMLString();
date_txt.text="UPDATED: "+my_xml.date[0];
congoal_txt.text=my_xml.peep1.consumer.goal;
constretch_txt.text=my_xml.peep1.consumer.stretch;
conactual_txt.text=my_xml.peep1.consumer.actual;
gotoAndPlay(2);
}
xmlLoader.load(xmlReq);
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
and then the second frame code:
stop();
function onProgress(e:ProgressEvent):void {
var temp1:String = congoal_txt.text.split(",").join("");
var congoal:Number = Number(temp1);
var temp2:String = constretch_txt.text.split(",").join("");
var constretch:Number = Number(temp2);
var temp3:String = conactual_txt.text.split(",").join("");
var conactual:Number = Number(temp3);
var loaded:Number=conactual;
var total:Number=congoal;
var pct=(loaded/total);
peepbar1_mc.bar1_mc.scaleX=pct;
loaded_txt.text=(Math.round(pct*100))+"%";
trace(pct);
trace(congoal_txt.text);
trace(constretch_txt.text);
trace(conactual_txt.text);
}
function onComplete(e:Event):void {
}
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS,onProgress);
this.loaderInfo.addEventListener(Event.COMPLETE,onComplete);
So basically my problem stems from the data not going to the second frame and then I need it to be numbers in order to create the percentage bar on the second frame based off the numbers…I understand XML and understand actionscript 3.0. any additional help is greatly appreciated… thank you in advance