flashgameblog.at

17.11.2009
21:49

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.

 

  1.  
  2. ast.trace("In europe children get their presents on 24. December in the evening.");
  3. ast.var_dump({a:1, b:"w", c:["hello", "world"], d:{a:1, b:2, c:3}});
  4. ast.trace( ast.println("In europe %0 get their presents on %1. December in the evening%2", ["children", 24, "."]) );
  5. ast.clear();
  6.  
  7.  
  8. var z:Number = 0;
  9. var finish:Number = 0;
  10.  
  11. for( var i:Number = 0; i < 5; i++){
  12.   finish = 1000+Math.random()*10000;
  13.   ast.timer_start()
  14.   for( var a:Number = 0; a < finish; a++)
  15.     z = --z +1;
  16.   ast.timer_stop();
  17. }
  18.  
  19. ast.timer_report();
  20. ast.timer_avg();
  21.  
  22. // if you don't call clear here the measurements
  23. // above are added to the report below.
  24. ast.timer_clear();
  25.  
  26. var z:Number = 0;
  27. var finish:Number = 0;
  28.  
  29. for( var i:Number = 0; i < 5; i++){
  30.   finish = 1000+Math.random()*10000;
  31.   var handle:Number = ast.timer_start()
  32.   for( var a:Number = 0; a < finish; a++)
  33.     z = --z +1;
  34.   ast.timer_stop(handle2);
  35. }
  36.  
  37. ast.timer_report();
  38. ast.timer_avg();
  39.  

 

Here you can download ast.as

 

  •  
  • 0 Comments
  •  

Your comment

Notify me when someone adds another comment to this post

back

< < November 2009 > >
S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          

Blog rolls

Latest Comments

Blur Filter
17.01.2011 11:01
ISO FTW!
18.09.2010 20:17
ISO Blender Camera Setup
24.04.2010 06:58
update
21.03.2010 01:15

Archive

  • [-]2010(9)
    • [-]November(1)
    • [-]August(1)
    • [-]July(1)
    • [-]June(2)
    • [-]April(1)
    • [-]March(2)
    • [-]February(1)
  • [-]2009(13)
    • [-]December(4)
    • [-]November(8)
    • [-]October(1)

Copy and paste this link into your RSS news reader

RSS 0.91Posts
RSS 2.0Posts

Social Bookmarking

Bookmark bei: Mr. Wong Bookmark bei: Webnews Bookmark bei: Icio Bookmark bei: Oneview Bookmark bei: Linkarena Bookmark bei: Favoriten Bookmark bei: Seekxl Bookmark bei: Favit Bookmark bei: Social Bookmarking Tool Bookmark bei: Power Oldie Bookmark bei: Bookmarks.cc Bookmark bei: Newskick Bookmark bei: Newsider Bookmark bei: Linksilo Bookmark bei: Readster Bookmark bei: Folkd Bookmark bei: Yigg Bookmark bei: Digg Bookmark bei: Del.icio.us Bookmark bei: Reddit Bookmark bei: Simpy Bookmark bei: StumbleUpon Bookmark bei: Slashdot Bookmark bei: Netscape Bookmark bei: Furl Bookmark bei: Yahoo Bookmark bei: Spurl Bookmark bei: Google Bookmark bei: Blinklist Bookmark bei: Blogmarks Bookmark bei: Diigo Bookmark bei: Technorati Bookmark bei: Newsvine Bookmark bei: Blinkbits Bookmark bei: Ma.Gnolia Bookmark bei: Smarking Bookmark bei: Netvouz Information