AS2 debugging script


/ Published in: ActionScript
Save to your folder(s)

This can be used instead of "trace" to populate a text field in addition to the standard trace output. The textfield stays hidden until a selected key combination is pressed, thus allowing you to use it in a staging or, if need be, a production environment while keeping it hidden.

Obviously it would be best to remove it from production when it debugging is finally complete, and you should change the key combination to something of your own making.


Copy this code and paste it in your HTML
  1. debugg("testing");
  2.  
  3.  
  4. //**************************** BEGIN DEBUG FUNCTION
  5. function debugg(whichText:String)
  6. {
  7. debug_txt.text += "\n\n" + whichText;
  8. trace("\n\n" + whichText + "\n\n");
  9. }
  10.  
  11. onEnterFrame = function() {
  12. if ((Key.isDown(Key.BACKSPACE))) {
  13. if ((Key.isDown(Key.LEFT))) {
  14. if (Key.getCode() == 17) { // so, press BACKSPACE+LEFT, and CONTROL (in that order, together) to reveal the debug
  15. debug_txt._y = Stage.height / 2;
  16. }
  17. }
  18. }
  19. };
  20. //**************************** END DEBUG FUNCTION

URL: http://files.getdropbox.com/u/316550/code-AS2_debugg.zip

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.