Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 47

Programming actionscript 3.0
Table of Contents

Advertisement

Using namespaces
You can find a real-world example of a namespace that is used to prevent name conflicts in the
flash.utils.Proxy class that is part of the Flash Player API. The Proxy class, which is the
replacement for the
Object.__resolve
intercept references to undefined properties or methods before an error occurs. All of the
methods of the Proxy class reside in the
conflicts.
To better understand how the
to use the Proxy class. The functionality of the Proxy class is available only to classes that
inherit from it. In other words, if you want to use the methods of the Proxy class on an object,
the object's class definition must extend the Proxy class. For example, if you want to intercept
attempts to call an undefined method, you would extend the Proxy class and then override the
method of the Proxy class.
callProperty()
You may recall that implementing namespaces is usually a three-step process of defining,
applying, and then referencing a namespace. Because you never explicitly call any of the Proxy
class methods, however, the
referenced. The Flash Player API defines the
Proxy class. Your code only needs to apply the
the Proxy class.
The
namespace is defined in the flash.utils package in a manner similar to the
flash_proxy
following:
package flash.utils
{
public namespace flash_proxy;
}
The namespace is applied to the methods of the Proxy class as shown in the following excerpt
from the Proxy class:
public class Proxy
{
flash_proxy function callProperty(name:*, ... rest):*
flash_proxy function deleteProperty(name:*):Boolean
...
}
As the following code shows, you must first import both the Proxy class and the
namespace. You must then declare your class such that it extends the Proxy class (you must
also add the
dynamic
method, you must use the
callProperty()
package
{
property from ActionScript 2.0, allows you to
flash_proxy
flash_proxy
namespace is only defined and applied, but never
flash_proxy
attribute if you are compiling in strict mode). When you override the
namespace in order to prevent name
namespace is used, you need to understand how
namespace and applies it in the
flash_proxy
namespace to classes that extend
flash_proxy
namespace.
flash_proxy
Packages and namespaces
flash_proxy
47

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents