User Guide
Packages and namespaces 45
If a namespace is defined within a package or a class, the namespace may not be visible to code
outside that package or class unless the appropriate access control specifier is used. For
example, the following code shows the
flash_proxy namespace defined within the flash.utils
package. In the following example, the lack of an access control specifier means that the
flash_proxy namespace would be visible only to code within the flash.utils package and
would not be visible to any code outside the package:
package flash.utils
{
namespace flash_proxy;
}
The following code uses the public attribute to make the flash_proxy namespace visible to
code outside the package:
package flash.utils
{
public namespace flash_proxy;
}
Applying namespaces
Applying a namespace means placing a definition into a namespace. Definitions that can be
placed into namespaces include functions, variables, and constants (you cannot place a class
into a custom namespace).
Consider, for example, a function declared using the
public access control namespace. Using
the
public attribute in a function definition places the function into the public namespace,
which makes the function available to all code. Once you have defined a namespace, you can
use the namespace that you defined the same way you would use the
public attribute, and
the definition will be available to code that can reference your custom namespace. For
example, if you define a namespace
example1, you can add a method called myFunction()
using example1 as an attribute, as the following example shows:
namespace example1;
class someClass
{
example1 myFunction() {}
}
Declaring the myFunction() method using the namespace example1 as an attribute means
that the method belongs to the
example1 namespace.