Flash gets XML but the values are wrong, as3

Posted by VideoDnd on Stack Overflow See other posts from Stack Overflow or by VideoDnd
Published on 2010-04-13T21:00:37Z Indexed on 2010/04/13 21:03 UTC
Read the original article Hit count: 399

Filed under:
|

Flash receives the XML, but the values are wrong. How do I fix this?

Problem
I can see the XML loaded with no errors, but my output is way off. It's as though it's not receiving any values. Numbers in the output window and animation move rapidly. The Flash file runs as if it's variables where set to zero. I changed the order of my code, but that didn't help with this. Please explain how I can correct this.

SWF

//load xml
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("xml.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
//parse XML
function processXML(e:Event):void {
myXML = new XML(e.target.data);
trace(myXML);
//receive values from XML
delay = parseInt(myXML.DELAY.text());
trace(delay);   
repeat = parseInt(myXML.REPEAT.text());
trace(repeat);  
}
//variables
var delay:uint = 0;
var repeat:uint = 0;
//timer and event
var timer:Timer = new Timer(uint(delay),uint(repeat));
timer.addEventListener(TimerEvent.TIMER, countdown);
//counter
function countdown(event:TimerEvent) {
myText.text = String(0 + timer.currentCount);
trace(0 + timer.currentCount);
}
timer.start();

XML

<?xml version="1.0" encoding="utf-8"?>
<SESSION>
<DELAY TITLE="starting position">1000</DELAY>
<REPEAT TITLE="starting position">60</REPEAT>
</SESSION>

© Stack Overflow or respective owner

Related posts about flash

Related posts about actionscript-3