Verbatim strings in ActionScript

Ignore escape sequences with @”” strings

Apache Royale adds support for declaring verbatim strings in ActionScript. Verbatim strings start with a @ character and don’t treat the \ character as the start of an escape sequence.

Requires Apache Royale 0.9.10 or newer.

Code example

Consider the following code that prints a regular string to the debug console:

var regular:String = "one\ntwo";
trace(regular);

In the debug console output, the \n sequence within a regular string will be displayed as a new line.

one
two

The following code prints a verbatim string to the debug console.

var verbatim:String = @"one\ntwo";
trace(verbatim);

In the debug console output, \ and n in a verbatim string are displayed as distinct characters.

one\ntwo

Limitations of verbatim strings in Royale

Other ActionScript compilers, such as the one in the Apache Flex SDK, may not recognize verbatim strings. Attemping to pass ActionScript or MXML source code that contains verbatim strings to another compiler may result in compile-time errors. In other words, to write 100% portable ActionScript code that works with any compiler, avoid using verbatim strings and any of Royale’s other extensions to the ActionScript language.