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

Creating Namespaces

To create a namespace, we must give it a name. The name of each namespace—known formally as the namespace name—is a string that, by convention, specifies a uniform resource identifier, or URI. The URI uniquely identifies the namespace among all other namespaces in a program and potentially even among any program in the world.

Tip

The term URI refers to the generalized resource-identification standard of which the familiar Internet address standard, URL, is a subtype. See http://www.ietf.org/rfc/rfc2396.txt.

ActionScript's use of URIs as namespace names is based on the standard set by the World Wide Web Consortium (W3C) in their "Namespaces in XML" recommendation. See http://www.w3.org/TR/xml-names11.

The first step in creating a namespace, then, is to decide on a URI to use as its name.

Choosing the Namespace URI

Typically, the URI used as a namespace name is a URL within the control of the organization producing the code. For example, my web site is www.moock.org, so for a new namespace name, I might use a URI generally structured like this:

http://www.moock.org/app/namespace

For the child's game that we're going to build, we'll use the following URIs for the namespaces fruit and color:

http://www.example.com/games/kidsgame/fruit
http://www.example.com/games/kidsgame/color

Note that the URI need not—and generally does not—exist online. The URI is used only to identify the namespace; it is not a web page address, or an XML document address, or any other online resource. ...

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