[Laszlo-dev] hey, interesting classes in the as3 flash.utils package

P T Withington ptw at pobox.com
Tue Feb 12 14:08:15 PST 2008


We should use Dictionary as the implementation of LzInheritedHash.  (I  
actually wrote a JS1 Dictionary class and it is in the LFC, but I  
decided it was too slow to use.)

On 2008-02-12, at 15:06 EST, Henry Minsky wrote:

> First, there is a hash table that uses object equality. Presumably it
> is implemented in an efficient manner...
>
> Package	flash.utils
> Class	public dynamic class Dictionary
> Inheritance	Dictionary Inheritance Object
>
> Language Version : 	ActionScript 3.0
> Player Version : 	Flash Player 9
>
> The Dictionary class lets you create a dynamic collection of
> properties, which uses strict equality (===) for key comparison on
> non-primitive object keys. When an object is used as a key, the
> object's identity is used to look up the object, and not the value
> returned from calling toString() on it. Primitive (built-in) objects,
> like Numbers, in a Dictionary collection behave in the same manner as
> they do when they are the property of a regular object.
>
>
>
>
> Second, there is a class called Proxy, that lets you dynamically
> create getters and setters. We seem to be
> pushing all of that to compile time, but there might be some use for  
> this..
>
> Package	flash.utils
> Class	public class Proxy
> Inheritance	Proxy Inheritance Object
>
> Language Version : 	ActionScript 3.0
> Player Version : 	Flash Player 9
>
> The Proxy class lets you override the default behavior of ActionScript
> operations (such as retrieving and modifying properties) on an object.
>
> The Proxy class has no constructor, and you should not attempt to
> instantiate Proxy. Instead, subclass the Proxy class to override
> methods such as getProperty and provide custom behavior. If you try to
> use a method of the Proxy class without overriding the method, an
> exception is thrown.
>
> And, keep in mind, your own code overriding the methods of the Proxy
> class can throw exceptions unintentionally. Throwing exceptions when
> using these methods causes problems because the calling code (using
> operators like in, is, delete and others) does not expect exceptions.
> Unless you're already sure your overriding method does not throw
> exceptions, Adobe recommends using try..catch statements around your
> implementation of the Proxy class to avoid fatal errors when operators
> call your methods. For example:
>
> dynamic class MyProxy extends Proxy {
>     flash_proxy override function callProperty(name:*, ...rest):* {
>       try {
>         // custom code here
>       }
>       catch (e:Error) {
>         // respond to error here
>       }
> }
>
>
> The Proxy class is a replacement for the Object.__resolve and
> Object.addProperty features of ActionScript 2.0, which are no longer
> available in ActionScript 3.0. The Object.addProperty() feature
> allowed you to dynamically create get and set methods in ActionScript
> 2.0. Although ActionScript 3.0 provides get and set methods at compile
> time, you cannot dynamically assign one to an object unless you use
> the Proxy class.
>
> To avoid collisions with the public namespace, the methods of the
> Proxy class are in the flash_proxy namespace.
>
> Where methods of the Proxy class take a name argument, name can be
> either a String or a QName object (if namespaces are being used).
> -- 
> Henry Minsky
> Software Architect
> hminsky at laszlosystems.com



More information about the Laszlo-dev mailing list