User Guide
Global Functions 53
Example
The following code produces the result
someuser%40somedomain%2Ecom:
var email:String = "someuser@somedomain.com";
trace(escape(email));
In this example, the at symbol (@) was replaced with %40 and the dot symbol (.) was replaced
with
%2E. This is useful if you're trying to pass information to a remote server and the data has
special characters in it (for example,
& or ?), as shown in the following code:
var redirectUrl:String = "http://
www.somedomain.com?loggedin=true&username=Gus";
getURL("http://www.myothersite.com?returnurl="+ escape(redirectUrl));
See also
unescape function
eval function
eval(expression:Object) : Object
eval(expression:String) : Object
Accesses variables, properties, objects, or movie clips by name. If expression is a variable or a
property, the value of the variable or property is returned. If expression is an object or movie
clip, a reference to the object or movie clip is returned. If the element named in expression
cannot be found, undefined is returned.
In Flash 4,
eval() was used to simulate arrays; in Flash 5 or later, you should use the Array
class to simulate arrays.
In Flash 4, you can also use
eval() to dynamically set and retrieve the value of a variable or
instance name. However, you can also do this with the array access operator (
[]).
In Flash 5 or later, you cannot use
eval() to dynamically set and retrieve the value of a
variable or instance name, because you cannot use
eval() on the left side of an equation. For
example, replace the code
eval ("var" + i) = "first";
with this:
this["var"+i] = "first"
or this:
set ("var" + i, "first");
Availability: ActionScript 1.0; Flash Player 5 - Flash Player 5 or later for full functionality.
You can use the
eval() function when exporting to Flash Player 4, but you must use slash
notation and can access only variables, not properties or objects.