Copy link to clipboard
Copied
Using AS3 in flash CS4
Hi i have some imported text from a tab delimited/seperated text file (.txt).
I have split the values into an array using .split('\n') .split('\t')
I have stored the imported data into an array where each column has a new index and the properties of each row can be gained from array
This all works fine however some of the separated strings are formatted incorrectly as they take up 2 lines instead of one.
The first string in each line in the original text file is imported into flash with a new line above it. I.e: "Property1" in the original tab delimited/seperated text file is stored in flash as "
Property1" with a new line above it. I need to get rid of this new line in order to appropriately display the text in text fields.
Can someone please help.
P.S: I do not want to change my importing file format from a tab delimited text file to something like xml so please don't suggest it.
those are not string-strip functions. those are whitespace characters. all whitespace characters are escaped by the backslash character.
i used two of them and in my years of using flash i've never used more than those two and \t = tab, though i know of two more:
\b = backspace
\f = formfeed
i used:
\r = carriage return
\n = new line
the code i gave converted a newline, followed by a carriage return to a new line, only. and it converted a carriage return followed by a new line to a new line, only.
p
...Copy link to clipboard
Copied
some text editors add a new line and a carriage return. to remedy, use:
s=s.split("\r\n").join("\n").split("\n\r").join("\n");
before you apply the rest of your string methods.
Copy link to clipboard
Copied
Thanks that worked.
How does it work? - I don't know what .split('\r') does.
I'm guessing 'r' stands for Return but how is this different to new line - .split('\n')
Where can i find a list of what all string slip functions (.split('\n'),.split('\r'),.split('\t') ect...)
Thanks
Copy link to clipboard
Copied
those are not string-strip functions. those are whitespace characters. all whitespace characters are escaped by the backslash character.
i used two of them and in my years of using flash i've never used more than those two and \t = tab, though i know of two more:
\b = backspace
\f = formfeed
i used:
\r = carriage return
\n = new line
the code i gave converted a newline, followed by a carriage return to a new line, only. and it converted a carriage return followed by a new line to a new line, only.
please mark this thread as answered, if you are still able.
Copy link to clipboard
Copied
thanks very much
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now