is supported in part by

April 09, 2007

Chapter 17, Paragraphs 1-5, Essential ActionScript 3.0

Here are the first 5 paragraphs of Chapter 17 of Essential ActionScript 3.0

17. Namespaces

In very general terms, a namespace is a set of names that contains no duplicates. That is, within the set, each name is unique. For example, in English, the names of fruits could be considered a namespace because each fruit has its own unique name—apple, pear, orange, and so on. Likewise, the names of colors could be considered a namespace because each color has its own unique name—blue, green, orange, and so on.

Notice that the name “orange” appears in both groups of names. The name “orange” itself is not unique, it is unique only within each group. Depending on whether you’re talking about a fruit or a color, the same name, “orange”, refers to two different things. That’s the purpose of namespaces. They let the same name (identifier) have different meanings depending on the context in which it is used.

When applied to programming, this “same name, different meaning” feature of namespaces offers two general benefits:

* It helps programmers avoid name conflicts
* It lets a program’s behavior adapt to the current context

Over the course of this chapter, we’ll explore the many nooks and crannies of namespaces in ActionScript. Try not to let the various details distract you from the relative simplicity of namespaces. Fundamentally, namespaces are nothing more than a two-part naming system. They are used to distinguish one group of names from another, much like an area code distinguishes one phone number from other phone numbers around the world.

Posted by moock at April 9, 2007 09:22 PM