Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

senocular.com ActionScript Library

output.as

Name: output - trace alternative w/ return
Author: senocular: www.senocular.com
Date: 1899-12-31T00:18:28.300
Documentation:
Function OUTPUT: Simple trace alternative that returns 
the value being traced (so it can be used inline)
with the option of disablement.

output.enabled
- property of output which, when true (default) will trace the value passed
for all instances of output.  When false, there is no trace for any instances
of its use (the object is still returned).

Example:
bob = new Object();
bob.toString = function(){
	return "my name is bob";
};

var value = output(bob); // traces "my name is bob"
trace(value); // traces "my name is bob"

1
2
3
4
_global.output = function(obj){
	if (_global.output.enabled) trace(obj);
	return obj;
};output.enabled = true;