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
and the dot symbol (
) was replaced
@
%40
.
with
. This is useful if you're trying to pass information to a remote server and the data has
%2E
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,
was used to simulate arrays; in Flash 5 or later, you should use the Array
eval()
class to simulate arrays.
In Flash 4, you can also use
to dynamically set and retrieve the value of a variable or
eval()
instance name. However, you can also do this with the array access operator (
).
[]
In Flash 5 or later, you cannot use
to dynamically set and retrieve the value of a
eval()
variable or instance name, because you cannot use
on the left side of an equation. For
eval()
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
function when exporting to Flash Player 4, but you must use slash
eval()
notation and can access only variables, not properties or objects.
Global Functions
53
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?
Questions and answers