Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 48

Programming actionscript 3.0
Table of Contents

Advertisement

import flash.utils.Proxy;
import flash.utils.flash_proxy;
dynamic class MyProxy extends Proxy
{
flash_proxy override function callProperty(name:*, ...rest):*
{
trace("method call intercepted: " + name);
}
}
}
If you create an instance of the MyProxy class and call an undefined method, such as the
method called in the following example, your Proxy object intercepts the method
testing()
call and executes the statements inside the overridden
a simple
statement).
trace()
var mySample:MyProxy = new MyProxy();
mySample.testing(); // method call intercepted: testing
There are two advantages to having the methods of the Proxy class inside the
namespace. First, having a separate namespace reduces clutter in the public interface of any
class that extends the Proxy class. (There are about a dozen methods in the Proxy class that
you can override, all of which are not designed to be called directly. Placing all of them in the
public namespace could be confusing.) Second, use of the
name conflicts in case your Proxy subclass contains instance methods with names that match
any of the Proxy class methods. For example, you may want to name one of your own
methods
callProperty()
method is in a different namespace:
callProperty()
dynamic class MyProxy extends Proxy
{
public function callProperty() {}
flash_proxy override function callProperty(name:*, ...rest):*
{
trace("method call intercepted: " + name);
}
}
Namespaces can also be helpful when you want to provide access to methods or properties in
a way that cannot be accomplished with the four access control specifiers (
, and
internal
protected
out across several packages. You want these methods available to all of your packages, but you
don't want the methods to be public. To accomplish this, you can create a new namespace and
use it as your own special access control specifier.
48
ActionScript Language and Syntax
. The following code is acceptable because your version of the
). For example, you may have a few utility methods that are spread
method (in this case,
callProperty()
namespace avoids
flash_proxy
public
flash_proxy
,
,
private

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents