Some arrays can have large amounts of data at each index, making it diffucult to read sometimes for debugging purposes, ecspecially in the output window. A nice way for the output window is:
<pre><code>
trace(my_array.join(newline));</code></pre>
Or for HTML content in a text field (say a custom debugger you made in Flash):
<pre><code>
trace(my_array.join(“<br />”));</code></pre>
These will display each piece of data on a newline so you don’t have to scroll horizontally and visually mark the next index by spotting the comma’s mixed in (which are the default).
thanks for that small but useful tip! this always was a pain!
I made these extensions recently to help me read an array easier…
String.prototype.print = function ()
{
return ‘”‘ + this + ‘”‘;
};
ASSetPropFlags(String.prototype, “print”, 7);
Object.prototype.print = function ()
{
var str = “{“;
for (var i in this)
str += i + “:” + (this[i] == null ? “null” : this[i].print()) + “, “;
return str.substr(0, str.length – 2) + “}”;
};
ASSetPropFlags(Object.prototype, “print”, 7);
Number.prototype.print = function ()
{
return this.toString();
};
ASSetPropFlags(Number.prototype, “print”, 7);
Boolean.prototype.print = function ()
{
return this.toString();
};
ASSetPropFlags(Boolean.prototype, “print”, 7);
Array.prototype.print = function ()
{
var str = “[“;
var l = this.length;
for (var i = 0; i
oooops i didnt put my name on the post – how rude….