User Guide

44 ActionScript Language and Syntax
There are three basic steps to follow when using namespaces. First, you must define the
namespace using the
namespace keyword. For example, the following code defines the
version1 namespace:
namespace version1;
Second, you apply your namespace by using it instead of an access control specifier in a
property or method declaration. The following example places a function named
myFunction() into the version1 namespace:
version1 function myFunction() {}
Third, once youve applied the namespace, you can reference it with the use directive or by
qualifying the name of an identifier with a namespace. The following example references the
myFunction() function through the use directive:
use namespace version1;
myFunction();
You can also use a qualified name to reference the myFunction() function, as the following
example shows:
version1::myFunction();
Defining namespaces
Namespaces contain one value, the Uniform Resource Identifier (URI), which is sometimes
called the namespace name. A URI allows you to ensure that your namespace definition is
unique.
You create a namespace by declaring a namespace definition in one of two ways. You can
either define a namespace with an explicit URI, as you would define an XML namespace, or
you can omit the URI. The following example shows how a namespace can be defined using a
URI:
namespace flash_proxy = “http://www.adobe.com/flash/proxy”;
The URI serves as a unique identification string for that namespace. If you omit the URI, as
in the following example, the compiler will create an unique internal identification string in
place of the URI. You do not have access to this internal identification string.
namespace flash_proxy;
Once you define a namespace, with or without a URI, that namespace cannot be redefined in
the same scope. An attempt to define a namespace that has been defined earlier in the same
scope results in a compiler error.