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

wonderfl trace

Howto:
1. cut and paste everything bellow the "WONDERFL TRACE" line to the end of your script
2. insert inittrace(stage); to the constructor of your main class
3. done!
Get Adobe Flash player
by kalevionni 27 May 2009
/**
 * Copyright kalevionni ( http://wonderfl.net/user/kalevionni )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/hCok
 */

// Howto:
// 1. cut and paste everything bellow the "WONDERFL TRACE" line to the end of your script
// 2. insert inittrace(stage); to the constructor of your main class
// 3. done!
 package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.text.TextField;
    
    public class TraceTest extends Sprite {
        
        public function TraceTest() {
            
            //This is all the initialization you need in your main class
            inittrace(stage);
            
            // demonstration
            trace("Hello","World!",1,2,3,stage,5);
            trace("Something else");
            trace(stage);
            trace(794613);
            trace("wonderfl!");
        }
        
    }
}



/////  WONDERFL TRACE /////

import flash.display.Sprite;
import flash.display.Stage;
import flash.text.TextField;
import flash.text.TextFormat;


function inittrace(s:Stage):void
{
    WTrace.initTrace(s);
}

//global trace function
var trace:Function;

//wtreace class
class WTrace
{
        private static var FONT:String = "Fixedsys";
        private static var SIZE:Number = 12;
        private static var TextFields:Array = [];
        private static var trace_stage:Stage;
        
        public static function initTrace(stg:Stage):void
        {
            trace_stage = stg;
            trace = wtrace;
        }
        
        private static function scrollup():void
        {
            // maximum number of lines: 100
            if (TextFields.length > 100) 
            {
                var removeme:TextField = TextFields.shift();
                trace_stage.removeChild(removeme);
                removeme = null;
            }
            for(var x:Number=0;x<TextFields.length;x++)
            {
                (TextFields[x] as TextField).y -= SIZE*1.2;
            }
        }
    
        public static function wtrace(... args):void
        {
        
            var s:String="";
            var tracefield:TextField;
            
            for (var i:int;i < args.length;i++)
            {
                // imitating flash:
                // putting a space between the parameters
                if (i != 0) s+=" ";
                s+=args[i].toString();
            }
            

            tracefield= new TextField();
            tracefield.autoSize = "left";
            tracefield.text = s;
            tracefield.y = trace_stage.stageHeight - 20;

            var tf:TextFormat = new TextFormat(FONT, SIZE);
            tracefield.setTextFormat(tf);
            trace_stage.addChild(tracefield);
            scrollup();                      
            TextFields.push(tracefield);
            
        }
}