PDA

View Full Version : outputting array on multiple lines



pipspeak
January 13th, 2004, 04:33 AM
I have a movieclip that calls an array, but I want that array to be output on multiple lines in the movie. How do I break up an array in such a way that it is output with the equivalent of line breaks?

for example, if an array is defined like this:

phrase = new Array();
thewords="this is line 1 text, this is line 2 text, but it's all going to be on the same line";
phrase=thewords.split(',');


When the movieclip pulls in the chunks of that array it sticks them all on one line. Is it possible to include some element in the code above to split the elements of the array onto multiple lines when it's output? Is there an equivalent to perl's "/n" which prints a line break, for example? I'd prefer that option than having to create multiple arrays and reengineer the entire function. Thanks.

APDesign
January 13th, 2004, 04:57 AM
\n is what you are looking for :thumb:
eg


trace("W\nO\nW\nZ\nA");


While I'm at it


\b // Backspace character
\f // Form feed character
\n // Newline Charater; cause a line break.
\r // Carriage return (CR) character; causes a line break
\t // Tab character
\ ' // Single quotation mark (no space though, **** formatting)
\" // Double quotation mark

so in other words, \ is the escape character.
I have no clue what the first two actually do.
eg


trace("Hey\nThis\nIs\nCool\n\ttabbed\n\"BLAH,\" Said D\'arcy.");

pipspeak
January 13th, 2004, 02:38 PM
I always get my slashes the wrong way round :puzzle:

Thanks for the other code hints too.