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: Minimum time resolution

Get Adobe Flash player
by yonatan 26 Feb 2011
    Embed
/**
 * Copyright yonatan ( http://wonderfl.net/user/yonatan )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7eWt
 */

// forked from 9re's Minimum time resolution
package {
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.utils.getTimer;
    import flash.utils.setTimeout;
    import flash.text.TextField;
    import flash.display.Sprite;
    import net.hires.debug.Stats;
    
    public class FlashTest extends Sprite {
        public function FlashTest() {
            stage.frameRate = 200;
            var tf:TextField = new TextField;
            var t:int;
            addChild(tf);
            tf.scaleX = tf.scaleY = 4;
            var s:Stats = new Stats;
            addChild(s);
            s.scaleX = s.scaleY = 5;
            s.y = 80;
            var timer:Timer = new Timer(0);
            timer.addEventListener(TimerEvent.TIMER, onTimer);
            timer.start();
            var lastTimeSampled:int = 0;
            
            function onTimer(event:TimerEvent):void {
                if ((t - lastTimeSampled) > 1000) {
                    lastTimeSampled = getTimer();
                    tf.text = (lastTimeSampled - t) + ' ms';
                }
                t = getTimer();
            }
        }
    }
}