Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 46

Programming actionscript 3.0
Table of Contents

Advertisement

You should bear in mind the following when applying namespaces:
You can apply only one namespace to each declaration.
There is no way to apply a namespace attribute to more than one definition at a time. In
other words, if you want to apply your namespace to ten different functions, you must
add your namespace as an attribute to each of the ten function definitions.
If you apply a namespace, you cannot also specify an access control specifier because
namespaces and access control specifiers are mutually exclusive. In other words, you
cannot declare a function or property as
addition to applying your namespace.
Referencing namespaces
There is no need to explicitly reference a namespace when you use a method or property
declared with any of the access control namespaces, such as
and
. This is because access to these special namespaces is controlled by context. For
internal
example, definitions placed into the
within the same class. For namespaces that you define, however, such context sensitivity does
not exist. In order to use a method or property that you have placed into a custom namespace,
you must reference the namespace.
You can reference namespaces with the
with the namespace using the name qualifier (
the
directive "opens" the namespace, so that it can apply to any identifiers
use namespace
that are not qualified. For example, if you have defined the
access names in that namespace by using
use namespace example1;
myFunction();
You can open more than one namespace at a time. Once you open a namespace with
, it remains open throughout the block of code in which it was opened. There is no
namespace
way to explicitly close a namespace.
Having more than one open namespace, however, increases the likelihood of name conflicts.
If you prefer not to open a namespace, you can avoid the
qualifying the method or property name with the namespace and the name qualifier
punctuator. For example, the following code shows how you can qualify the name
with the
myFunction()
example1::myFunction();
46
ActionScript Language and Syntax
public
private
use namespace
use namespace example1
namespace:
example1
,
,
private
protected,
public
namespace are automatically available to code
directive or you can qualify the name
) punctuator. Referencing a namespace with
::
example1
use namespace
or
internal
,
,
private
protected
namespace, you can
:
use
directive by
in
,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents