Skip to main content
Matt Coates Art
Participant
January 6, 2016
Answered

Counter in Flash

  • January 6, 2016
  • 1 reply
  • 531 views

I'm currently working on a Flash animation that requires a counter from $0-$100,000 which will be converted into a movie for a website, how easy can this be done in flash?

It needs to start 'onframe' and will not have a button to start the counter.

Thanks!

This topic has been closed for replies.
Correct answer nezarov

- Create a dynamic text field on the stage > give it an instance name > embed the font you want to use

- Add the following code in frame one:

var currentCount = 0;

var totalCount = 1000000;

addEventListener(Event.ENTER_FRAME, onEF);

function onEF(e:Event):void

{

     currentCount +=1;

     textFieldName.text = "$ " + currentCount;

    

     /// If you want to repeat it or you want to do anything on complete count:

     if (currentCount == totalCount)

     {

          //reset the currentCount:

          currentCount = 0;

          // If you want to stop the counter:

          // removeEventListener(Event.ENTER_FRAME, onEF);

     }

}

1 reply

nezarovCorrect answer
Inspiring
January 6, 2016

- Create a dynamic text field on the stage > give it an instance name > embed the font you want to use

- Add the following code in frame one:

var currentCount = 0;

var totalCount = 1000000;

addEventListener(Event.ENTER_FRAME, onEF);

function onEF(e:Event):void

{

     currentCount +=1;

     textFieldName.text = "$ " + currentCount;

    

     /// If you want to repeat it or you want to do anything on complete count:

     if (currentCount == totalCount)

     {

          //reset the currentCount:

          currentCount = 0;

          // If you want to stop the counter:

          // removeEventListener(Event.ENTER_FRAME, onEF);

     }

}

Matt Coates Art
Participant
January 6, 2016

Great, thanks nezarov for your help!

Inspiring
January 7, 2016

You're welcome.