开发者

RangeError 2066, XML and AS3

开发者 https://www.devze.com 2022-12-24 05:35 出处:网络
I\'m working with XML and Flash. I tried to pass XML values to my timer and got a Range Error. How do I fix this?

I'm working with XML and Flash. I tried to pass XML values to my timer and got a Range Error. How do I fix this?

My Error

RangeError: Error #2066: The Timer delay specified is out of range.

at Error$/throwError()

at flash.utils::Timer()

开发者_StackOverflow at svrReadyXML_fla::MainTimeline/frame1()

My SWF 'Receives XML for Timer function'

import flash.display.Sprite; 
import flash.events.Event; 
import flash.utils.Timer; 
import flash.events.TimerEvent; 

var timer:Timer; 
timer = new Timer( speed );
var speed:Number = Number( myXML.TIMER.text() );
var fcount:int = 0;
var count:int = 0;

timer = new Timer(speed); 
//timer.addEventListener(TimerEvent.TIMER, incrementCounter);     
timer.start();

//LOAD XML
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("time.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);

//PARSE XML
function processXML(e:Event):void {
myXML = new XML(e.target.data);
trace(myXML.COUNT.text()); 
trace(myXML.FCOUNT.text()); 
trace(myXML.TIMER.text()); 
}


You're trying to read myXML.TIMER value before loading your XML file. It probably returns null, which causes your problem. Try to initialize your timer in your processXML function.

function processXML(e:Event):void {
myXML = new XML(e.target.data);
timer = new Timer( Number(myXML.TIMER.text()) );
timer.start();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消