Understanding the ActionScript Language > About data types > String |
![]() ![]() ![]() |
String
A string is a sequence of characters such as letters, numbers, and punctuation marks. You enter strings in an ActionScript statement by enclosing them in single or double quotation marks. Strings are treated as characters instead of as variables. For example, in the following statement, "L7"
is a string:
favoriteBand = "L7";
You can use the addition (+)
operator to concatenate, or join, two strings. ActionScript treats spaces at the beginning or end of a string as a literal part of the string. The following expression includes a space after the comma:
greeting = "Welcome," + firstName;
Although ActionScript does not distinguish between uppercase and lowercase in references to variables, instance names, and frame labels, literal strings are case sensitive. For example, the following two statements place different text in the specified text field variables, because "Hello"
and "HELLO"
are literal strings.
invoice.display = "Hello"; invoice.display = "HELLO";
To include a quotation mark in a string, precede it with a backslash character (\). This is called "escaping" a character. There are other characters that cannot be represented in ActionScript except by special escape sequences. The following table provides all the ActionScript escape characters:
Escape sequence |
Character |
---|---|
|
Backspace character (ASCII 8) |
|
Form-feed character (ASCII 12) |
|
Line-feed character (ASCII 10) |
|
Carriage return character (ASCII 13) |
|
Tab character (ASCII 9) |
|
Double quotation mark |
|
Single quotation mark |
|
Backslash |
|
A byte specified in octal |
|
A byte specified in hexadecimal |
|
A 16-bit Unicode character specified in hexadecimal |
![]() ![]() ![]() |