【发布时间】:2011-01-31 18:14:00
【问题描述】:
我的动画向前推进,但它被冻结了。它抛出一个 TypeError 1009。我如何摆脱这个错误并让它发挥作用?
下载
http://sandboxfun.weebly.com/
XML
<?xml version="1.0" encoding="utf-8"?>
<SESSION>
<TIMER TITLE="speed">1000</TIMER>
<COUNT TITLE="starting position">10000</COUNT>
</SESSION>
FLA
//DynamicText 'Count'
var timer:Timer = new Timer(10);
var count:int = 0;
var fcount:int = 0;
timer.addEventListener(TimerEvent.TIMER, incrementCounter);
timer.start();
function incrementCounter(event:TimerEvent) {
count = myXML.COUNT.text();
count++;
fcount=int(count*count/1000);
mytext.text = formatCount(fcount);
}
function formatCount(i:int):String {
var fraction:int = i % 100;
var whole:int = i / 100;
return ("0000000" + whole).substr(-7, 7) + "." + (fraction < 10 ? "0" + fraction : fraction);
}
//LOAD XML
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("time.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
/*------CHANGED TIMER VALUE WITH XML------*/
timer = new Timer( Number(myXML.TIMER.text()) );
//timer.start();
//PARSE XML
function processXML(e:Event):void {
myXML = new XML(e.target.data);
trace(myXML.COUNT.text());
trace(myXML.TIMER.text());
}
//var count:int = 0;//give it a value type
/*------CHANGED COUNT VALUE WITH XML------*/
count = myXML.COUNT.text();
错误
TypeError:错误 #1009:无法访问 null 的属性或方法 对象引用。
在 _fla::MainTimeline/frame1()
类型错误:错误 #1009:无法访问空对象引用的属性或方法。
在 _fla::MainTimeline/incrementCounter()
在 flash.utils::Timer/_timerDispatch()
在 flash.utils::Timer/tick()
【问题讨论】:
标签: xml flash actionscript-3