In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: Counter / related with: BezierTest

then count it up!
Get Adobe Flash player
by diego 04 May 2009
    Embed
// forked from broken's Counter / related with: BezierTest
// then count it up!
//
package {

    import flash.display.*;
    import flash.events.Event;
    import flash.filters.GlowFilter;
    import flash.utils.getTimer;
    
    [SWF(backgroundColor="0x000000", frameRate="24", width="465", height="465")]
    public class Counter extends Sprite {
        
        private var _disp0 : CharDisplay;
        private var _disp1 : CharDisplay;
        
        private var _color : uint = 0xffffff;
        
        public function Counter()  {
            
            filters = [new GlowFilter(0xff0099, 1, 8, 8, 2) ];

            _disp0 = new CharDisplay();
            _disp0.x = 232.5;
            _disp0.y = 32.5;
            _disp0.color = _color;
            addChild(_disp0);

            _disp1 = new CharDisplay();
            _disp1.x = 32.5;
            _disp1.y = 32.5;
            _disp1.color = _color;
            addChild(_disp1);
            
            addEventListener(Event.ENTER_FRAME, enterFrameHandler);
        }
        
        private function enterFrameHandler(event : Event) : void {
            var count : int = getTimer() / 1000; // 1sec
            _disp0.c = String(count % 10);
            _disp1.c = String(int(count / 10) % 10);
        }

    }
}


import flash.display.*;
import flash.events.Event;


class CharDisplay extends Sprite {

    private static var _coordsMap : Object = {
0 : [97,48,28,75,23,201,20,365,102,364,173,352,172,200,166,107,116,71],
1 : [65,90,94,83,101,40,100,155,98,341,103,368,66,371,102,345,136,371],
2 : [50,106,100,0,157,88,185,137,104,236,54,297,42,371,100,348,159,369],
3 : [52,45,157,41,164,103,173,172,78,184,180,169,173,268,166,355,43,366],
4 : [100,42,33,123,25,279,99,242,168,275,70,275,117,147,111,262,115,371],
5 : [156,48,40,84,32,51,90,52,43,179,159,176,169,262,167,365,45,368],
6 : [143,51,48,66,32,180,19,352,102,370,181,355,176,267,126,108,18,267],
7 : [52,103,55,71,33,49,100,70,173,49,162,19,115,178,90,275,92,370],
8 : [99,32,0,104,140,221,200,290,101,374,0,302,61,222,191,103,123,47],
9 : [135,46,41,36,38,124,42,205,118,186,199,154,163,71,186,263,58,365]
    };

    private var _points : Array = new Array();

    public var color : uint = 0x000000;
    
    public var c : String = "0";

    public function CharDisplay() {
        addEventListener(Event.ENTER_FRAME, enterFrameHandler);
    }

    private function enterFrameHandler(event : Event) : void {

        var g : Graphics = graphics;
        g.clear();
        
        var targetPoints : Array = _coordsMap[c];
        if (!targetPoints) {
            return;
        }
        
        var i : int;
        var len : int = targetPoints.length - 4;

        // fill zeros            
        while (_points.length < targetPoints.length) {
            _points.push(0);
        }

        // avg.
        for (i = 0; i < _points.length; i++) {
            _points[i] = (_points[i] + targetPoints[i]) / 2;
        }
        
        g.lineStyle(8, color);        

        for (i = 0; i < len; i += 4) {

            if (i == 0) {
                g.moveTo(_points[i], _points[i + 1]);
            }

            g.curveTo(
                _points[i + 2], _points[i + 3], 
                _points[i + 4], _points[i + 5]);
        }
    }
}