This month Huw Collingbourne creates a more feature-rich descendent of the ActionScript Object class

What you will learn…
• How to create objects capable of manipulating their own associative arrays
• How to assign an associate array literal in a constructor
• How instance methods may reference static methods

What you should know…
• What an associative array is (explained in previous columns)
• How to iterate over keys and values in loops
• How to create a Library project using an ActionScript IDE

Last month I explained how to create a simple library of routines to manipulate the associative arrays (or hashes) contained within the Object class at the root of the ActionScript class hierarchy. Those routines took the form of static functions inside a class which I called ObjectHandler.
Static function provide a convenient way of manipulating objects sent to them as arguments. For example, the function shown below takes the Object argument, anOb. It iterates through the keys of its associative array and returns the keys as the elements of a simple array which is optionally sorted if the doSort argument is true:

To view the whole article, please follow the link:

ActionScript in Action: Writing A Better Object

Republished with the authorization of Flash and Flex Developers Magazine

Leave a Reply

Current day month ye@r *