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

Comparing Qualified Identifiers

Two namespaces are considered equal if, and only if, they have the same namespace name (URI). For example, to determine whether the namespaces in the qualified identifiers fruit::orange and color::orange are equal, ActionScript does not check whether the characters "fruit" in the first identifier match the characters "color" in second. Instead, ActionScript checks whether the Namespace instance referred to by fruit and the Namespace instance referred to by color have a matching uri variable value. If fruit.uri equals color.uri, then the namespaces are considered equal.

Therefore, when we write the following comparison:

trace(fruit::orange == color::orange);

ActionScript performs this comparison (notice the use of expanded names, discussed in the earlier section "Expanded Names"):

{http://www.example.com/games/kidsgame/fruit}orange
   == {http://www.example.com/games/kidsgame/color}orange

Hence, even though two qualified identifiers may look different on the surface, they might be the same, leading to perhaps surprising name conflicts. For example, in the following code, the attempted definition of the variable ns2::p is considered a compile-time error because a variable with the expanded name {http://www.example.com/general}p already exists:

namespace ns1 = "http://www.example.com/general"
namespace ns2 = "http://www.example.com/general"
ns1 var p:int = 1;
ns2 var p:int = 2;  // Error! Duplicate variable definition!

Even though the identifiers ns1 and ns2 are ...

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