Skip navigation
chris heyes
Currently Being Moderated

Need help creating a count-up animation

Jan 6, 2013 4:56 AM

HI. I'm new (ish) to FlashCS6 and need help creating a count up animation. I'm fine with general flash animation, but have never really used action script, so do need my hand holding a bit. any help would be great.

 

Basically I have 12 scenes depicting someone going about their daily life buying items and at the end of each scene I have a little cash graphic that pops up - I then need to numbers to quickly animate counting eg, from £0 to £369 over a couple of seconds.

 

thanks in advance

 

Chris

 
Replies
  • Currently Being Moderated
    Jan 6, 2013 5:33 AM   in reply to chris heyes

    You aren't likely to get your hand held without showing something of an effort to solve things yourself, but here's something to start with.  Your cash graphic will need to be a MovieClip or Sprite so that you can target it using code.  Let's say you assign that an instance name of "cashGraphic".  Inside of it you will have a dynamic textfield that you also need to name, so let's call that "cashDisplay"

     

    YOu will also need some variable somewhere in the main timeline that holds the total cash value... let's call that variable cashTotal

     

    To get it to gradually update the value to the final amount, the end of each scene will need to have code such as the following (assuming an AS3 solution)...

     

    stop();

     

    cashGraphic.addEventListener(Event.ENTER_FRAME, tallyCash);

     

    var cashValue = -1;  // will be used to count up from 0 to cashTotal

     

    function tallyCash(evt:Event):void {

         cashValue += 1;

         cashGraphic.cashDisplay.text = "£"+String(cashValue);

         if(cashValue == cashTotal){

              cashGraphic.removeEventListener(Event.ENTER_FRAME, tallyCash);

         }

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 7, 2013 1:51 AM   in reply to chris heyes

    Here is a good tutorial that explains the needed steps in detail:

    http://www.snorkl.tv/2010/09/how-to-tween-a-variable-with-flash-and-tw eenlite/

     

    You need to install TweenLite

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 14, 2013 12:00 PM   in reply to chris heyes

    The toFixed() method should do what you need.  Per my earlier sample code....

     

    cashGraphic.cashDisplay.text = "£"+cashValue.toFixed(2);

     

     

    The toFixed method returns a String value so you don't need to cast it as one in the coding like I showed earlier.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points