A Better Number Scrambler
For our current project we are designing and coding a laboratory themed microsite in Flash. The site requires programming lots of gadgety gizmos, one of which is a counter with a number scrambler before the counter finishes "computing" to display the final number or message.

However, we weren't satisfied with the other scrambler scripts using the "EnterFrame" code. Using EnterFrame will get the scrambler to change every frame, requiring more processing for the 24 frames. It also didn't allow for a lot of control.

So we wrote our own script based on a Timer which allows for more flexibility. You can designate how many numbers (or characters/symbols) should be generated within a specific timeframe. Essentially changing the characters X many times within Y time before displaying the correct one.

Example:
TextScrambler.scramble(textfield, "Any string", 1, 5, );

Within ( ) the variables are:
-textfield where the scrambling will take place
-any message or numbers
-total duration of the animation, number of times each character cycles before displaying the final one

Optional variables within specify:
-any combination of numbers, characters, or symbols.

Try it out in this Flash applet. Click "Scramble" to see result.

Alternative content

Get Adobe Flash player


Download Class
Leave Us A Comment


Spread The Love
Copied!