Copy link to clipboard
Copied
I'm creating an animated info graphic about tigers and need a count up from 0 to 3200 to show the current population of tigers in Asia.
This is my current Code:
var countUpInc:int = 1;
var totalSecs:int = 30000;
var countUp = 0;
var countTimer:Timer = new Timer(countUpInc);
countTimer.addEventListener(TimerEvent.TIMER, timerHandler);
countTimer.start();
function timerHandler(e:TimerEvent): void {
if (countUp == 3200) {
countTimer.stop();
countUp = totalSecs;
} else {
countUp = countUp + countUpInc;
counter.countertext.text = countUp;
trace(countUp);
}
}
the code runs and displays 300 then crashes as shown by the trace.
I get the error:
" TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TigerInfographic_fla::MainTimeline/timerHandler()[TigerInfographic_fla.MainTimeline::frame210:17]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick() "
i don't know how to fix it.
.fla file: NBeaulieu_FinalAnimation.zip - Google Drive
1 Correct answer
you need a movieclip named counter that has a textfield (countertext).
Copy link to clipboard
Copied
you need a movieclip named counter that has a textfield (countertext).

