AST - ASToolBox (AS2)
This time I want to share a tool for all AS2 coders out there.
I wrote it because I needed an easy to use trace tool for my projects written with flashdevelop. At this time trace in flashdevelop wasn't an easy step and I didn't want to read all the tutorials because they simply didn't solve the problems for my installation.
ASToolBox (short ast) is a static class which offers functions for tracing, var_dump and time measurement of code segments.
Installation:
Copy the class source code below in a .as file and safe it in the folder
C:\Dokumente und Einstellungen\[USERNAME]\Lokale Einstellungen\Anwendungsdaten\Adobe\Flash CS4\de\Configuration\Classes\FP8
trace data
To trace data ast offers three functions. Firstly there is trace. It's the most common function in flash, so I think I don't need to explain it.
Secondly there we have var_dump. It takes an Object and traces an analysed string of it. It's an flash equivalent of the PHP function.
And Finally println, it works very similar as the C equivalent, but it doesn't know data types. Everything is handled as a String. Actually it doesn't output anything. It just prepares and returns a string for output.
Additionally to these output functions there is clear, which simply clears the output window.
time measurement
Sometimes you want to measure the time that is taken for a peace of code to be executed. Ast gives you some functions to make this task very simple.
- ast.trace("In europe children get their presents on 24. December in the evening.");
- ast.var_dump({a:1, b:"w", c:["hello", "world"], d:{a:1, b:2, c:3}});
- ast.trace( ast.println("In europe %0 get their presents on %1. December in the evening%2", ["children", 24, "."]) );
- ast.clear();
- var z:Number = 0;
- var finish:Number = 0;
- for( var i:Number = 0; i < 5; i++){
- finish = 1000+Math.random()*10000;
- ast.timer_start();
- for( var a:Number = 0; a < finish; a++)
- z = --z +1;
- ast.timer_stop();
- }
- ast.timer_report();
- ast.timer_avg();
- // if you don't call clear here the measurements
- // above are added to the report below.
- ast.timer_clear();
- var z:Number = 0;
- var finish:Number = 0;
- for( var i:Number = 0; i < 5; i++){
- finish = 1000+Math.random()*10000;
- var handle:Number = ast.timer_start();
- for( var a:Number = 0; a < finish; a++)
- z = --z +1;
- ast.timer_stop(handle2);
- }
- ast.timer_report();
- ast.timer_avg();
Here you can download ast.as
- 0 Comments



Your comment