I use a ton of string tricks, I concatenate graphic names, do search and replaces on homemade HTML tags in XML attributes (cause you can’t use CDATA in attributes) strings are definately my lazy crutch, they work, easy to debug and like I said..I’m occassionally a lazy coder.
Even though I use them alot here’s are some of the string things that I occassionally forget, and perhaps I’m not the only one. Consider this your string cheatsheet:
in no particular order of usefulness:
Take any numeric string — like “5” subtract 0 from it, and the result is a Number (and yes I realize there are at
least 7 different ways of doing this..but this one is kind of intresting).
Flash doesn’t care from single or double quotes, but if you use doubles and you need to nest them you can escape the with a forward slash.
To find out how many words are in a string, simply split it using a space as a delimiter and return the
length.
\r and \n insert new lines in strings
\t is a tab which is fairly useless unless you also utilize <TEXTFORMAT>
while we’re mentioning <TEXTFORMAT> here’s a list of all the tags for that
<TEXTFORMAT //textfieldoptions with following attributes
BLOCKINDENT=”10” //distance from left border
INDENT=”10” //distance of first line from left
LEADING=”10” //lineheight
LEFTMARGIN=”10” //distance from left border
RIGHTMARGIN=” 15” //distance from right border
TABSTOPS=”10,100,1000”> //list of tabstop positions from left border
HTML lists are usefull, just remember that you don’t need UL tags
<LI> //new paragraph with a bullet point
If your exporting to Flash 6 your bullets are gonna be black, only solution I’ve found is to use the color object on
the whole textblock, which pretty much sucks.
Also a real bugger of a HTML bug
<b>This is a</b> <i>BUG</i> will render without the space between ‘a’ and ‘BUG’
here’s a tasty solution to fix this
So what’s you favorite string trick?






