O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Qualified-Identifier Visibility

Perhaps you noticed that none of the qualified-identifier definitions in this book include any access-control modifiers (public, internal, protected, or private). We've seen plenty of this:

fruit var orange:String = "Round citrus fruit";

But none of this (note the addition of the access-control modifier private):

private fruit var orange:String = "Round citrus fruit";

And for good reason: it is illegal to use access-control modifiers with definitions that include a qualifier namespace. For example, the following code:

private fruit var orange:String;

yields the error:

Access specifiers not allowed with namespace attributes

But if access-control modifiers are illegal, then what governs the accessibility of a qualified identifier? Answer: the accessibility of the identifier's qualifier namespace.

Tip

The accessibility of the qualifier namespace in a qualified identifier determines that identifier's accessibility. If the qualifier namespace is visible in a given scope, then the qualified identifier is also visible.

For example, in the expression gameitems.fruit::orange, the variable fruit::orange is accessible if and only if the namespace fruit is accessible in the scope where the expression occurs. The accessibility of the variable fruit::orange is entirely determined by the accessibility of the namespace fruit.

Example 17-2 demonstrates qualified identifier visibility with generic code.

Example 17-2. Qualified identifier visibility demonstration

// Create namespace ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required