Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help! How to create a count up in Animate?

New Here ,
Dec 14, 2017 Dec 14, 2017

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

517
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 15, 2017 Dec 15, 2017

you need a movieclip named counter that has a textfield (countertext).

Translate
Community Expert ,
Dec 15, 2017 Dec 15, 2017
LATEST

you need a movieclip named counter that has a textfield (countertext).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines