How would I make a counter using Greensocks TweenMax or TweenLite? Does anyone understand the overwrite manager?
My code will be in AS3. I want it to be timer based, and be capable
or resetting it’s self and looping. Advice or starter-code would be cool. Also, is it bad to use tweening engines? Let me know.
IDEAS
moving number column “increments by pixels”
0
1
2
3
4
5
6
7
8
9
0
//1
TweenMax.to
(num7, 1, {y:-3911, delay:1, paused:false, useFrames : false, immediateRender : false});
//2
TweenMax.to
(num7, 1, {y:85, delay:2, paused:false, useFrames : false, immediateRender : false});
//3
TweenMax.to
(num7, 1, {y:-3911, delay:3, paused:false, useFrames : false, immediateRender : false});
//4
TweenMax.to
(num7, 1, {y:85, delay:4, paused:false, useFrames : false, immediateRender : false});
//5
TweenMax.to
(num7, 1, {y:-3911, delay:5, paused:false, useFrames : false, immediateRender : false});
//6
TweenMax.to
(num7, 1, {y:85, delay:6, paused:false, useFrames : false, immediateRender : false});
//7
TweenMax.to
(num7, 1, {y:-3911, delay:7, paused:false, useFrames : false, immediateRender : false});
//8
TweenMax.to
(num7, 1, {y:85, delay:8, paused:false, useFrames : false, immediateRender : false});
//9
TweenMax.to
(num7, 1, {y:-3911, delay:9, paused:false, useFrames : false, immediateRender : false});
//10
Appearance “things appear and dissapear, similar to load-sprite-method”
“no example”
My Problems
-infinite looping motions
-global time-scaling and math floor
-garbage build up
It sounds like you have habit of over complicating things. I would probably not use a tweening engine, but might use the Timer class.
I would also separate things out into manageable chunks. At the moment it looks like you have your timing code and you display code all mixed in together. I would create these seperate parts:
Breaking it down like this means you can concentrate on one component at a time, and test that one part in isolation from the other parts. For example; first you could build the CounterView. This would probably be a MovieClip that holds your graphics on the stage. It might have a method called:
When this method is called, the CounterView will show the graphics for that number, including transitions. To test this component, just call this method from the CounterView parent, with a random number. Once it works you can start working on the CounterTimer.
For the CounterTimer you would probably want it to have a bit more of an API e.g.
When CounterTimer is finished, just start on the CounterController to hook them together. The CounterController would need to listen to the enterframe event, and tell CounterView to display CounterTimer’s count every frame.