Jump to content
Search Community

Rolling number effect

RockyW test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi All,

 

I'm new to AS and flash and trying to create a "Jackpot meter" looking signage which will display some dollar value. When value changes the number will be rolling towards to the new value.

 

Can anyone suggest any way to do this?

 

Thanks

Link to comment
Share on other sites

Believe it or not, the trick here is the easing!

 

I did something similar to kind of give a "slot machine" rolling aesthetic to the end of a sentence here

 

See the Pen rLdqLY by sgorneau (@sgorneau) on CodePen

 

 

What you'd want to focus on is the

 

ease:  Elastic.easeInOut.config(8, 0)

 

 

For your case, "8" might be too much ... so modify that to get the right feel for your project.

 

  • Like 7
Link to comment
Share on other sites

On 27/10/2017 at 7:48 PM, Shaun Gorneau said:

Believe it or not, the trick here is the easing!

 

I did something similar to kind of give a "slot machine" rolling aesthetic to the end of a sentence here

 

See the Pen rLdqLY by sgorneau (@sgorneau) on CodePen

 

What you'd want to focus on is the

 


ease:  Elastic.easeInOut.config(8, 0)

 

 

For your case, "8" might be too much ... so modify that to get the right feel for your project.

 

 

Thanks mate, that was what I'm looking for! 

 

I've tried to put the code into my project but seems like I can only get the animation done once, see below example code:

 

function IncreaseValue()
                                {
                                	//some process here to pass value to poolValue_mc.text;
                                
                                	TweenMax.to(poolValue_mc, 3,{y:1000,  ease: Elastic.easeInOut.config(0, 10)});
                                }

There is some other process to call this function every x seconds and I can see the value is keep changing but the animation, did I do anything wrong?

Link to comment
Share on other sites

Hi @RockyW,

 

It's very hard to troubleshoot issues "in the dark", without the code in context. Could you set up a simple example of what you are trying to achieve?

 

 

There are several ways of triggering a function every X seconds. Some with plain JavaScript, some with GSAP but it will depend on what you are trying to achieve really.

 

Using the code you provided, one way to go about it would be:

 

function waitCall() {
  TweenMax.delayedCall(1, IncreaseValue)
}


function IncreaseValue() {
  //some process here to pass value to poolValue_mc.text;
  TweenMax.to(poolValue_mc, 3,{
    y:1000,
    ease:Elastic.easeInOut.config(0, 10),
    onComplete:waitCall
  });
}

 

Note that your tween is not set to reset itself so, you won't see anything move after the first time it plays. Even if you were to reset it, you will end up with a flickering animation jumping around. What you really want to do is to create a carousel of numbers and rotate them at your specific rate, rather than just this one value.

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...