printr
SourceForge.net Logo
Inspector functions and Debugger Panel for Flash MX
Introduction
The printr displays human readable information about a variable - it's an Actionscript implementation of the print_r from PHP, with some Flash-specific features.
The variable can be a primitive data(number, string, boolean), or a structure(array, object, movieclip). In the second case the object will be displayed recursively, in a tree-like structure.
Hello World!
Include the following code in the first frame:
#include "printr_mx.as"
var a = new Array("Hello","World","!");
printr(a);
Now take a look at the Output window:
Hello,World,!
(
    [0] => Hello{string}
    [1] => World{string}
    [2] => !{string}
)
The Panel
You can access the panel from Window > Printr Debugger
Using the Printr Debugger Panel offers the following benefits:
  • The results from the different calls are registered into a "Table of Contents", it's no need to scroll the whole Oputput Window for a given object.
  • The panel receives printr results from movies running in a browser, or projector.
  • You can issue object inspections from the panel to a movie running in the Authoring environment, browser or projector.
Where are my results?
The results from the printr calls will be displayed either in the Output Window of the Flash Authoring, or in the Printr Debugger Panel:
  • if you include the printr_np.as (no panel) in your movie, the results will be displayed in the output window.
  • if you include the printr_mx.as and the Panel is opened, the results will be sent to the panel only.
  • if you include the printr_mx.as and the Panel is opened, but the printr is called from the first frame, the results will be displayed in both places.
  • if you include the printr_mx.as and the Panel is not opened, the results will be displayed in the output window.
I need that output!
If you want to use the results from a printr (for instance you want to display it in a TextField), you should use the returnr instead. It has the same parameters as printr.
Example
Documentation?
A detailed documentation can be found in the Reference Panel (Shift+F1) under the "Printr Debugger" entry after installing the mxp package.
The list of functions/includes from the package:
#include "printr_mx.as"
includes the necessary ActionScript files and the interaction with the Panel
#include "printr_np.as"
includes the necessary ActionScript files without the Panel interaction
printr(variable [,description [,optionString]]);
displays human-readable information about a variable
returnr(variable [,description [,optionString]]);
returns human-readable information about a variable
setPrintrOptions(optionString);
sets the global options for the printr and returnr functions
Download
printr and trace
If you plan to use the printr together with trace messages (while the panel is closed), and the order of the messages is important, you should use the printr_np.as version.
In the other case the printr first tries to send the results to the panel, and it sends to the Output window only after it observes that the panel is not available. If in the meantime a trace is executed, it will be displayed before the printr result.

Random thoughts - useful information
  • Read the printr and trace section, it could be important in some cases
  • Read about the option string (Reference Panel[Shift+F1] > Printr Debugger > Help > Option String structure) - maybe you'll never use it, but maybe it will help you a lot
  • Never leave the printr_mx.as or printr_np.as included in a published movie - others could spy your data
  • If you plan to use the Printr Panel outside of Flash Authoring, you should locate the "Printr Debugger.swf" on your filesystem (it's in a folder called WindowSWF somewhere deep on your harddisk), and create a projector from the swf
  • Performance: the evaluation of the data is performed in the main movie (the one that includes the printr_mx.as). In the case of big structures this can slow down the movie's performance.
  • Flash Warning: "A script in this movie is causing Flash Player to run slowly...". If you encounter this, it means that the datastructure you want to inspect is too big. In this case abort the script, and set the depth of printr width the "D" flag in the optionString.
    Example: printr(obj,"big data","D1");