All classes extend
Object—it is the root of the ActionScript class hierarchy. Despite their inauspicious roots,
Objects can be truly useful as a data structure. In Chapter 8, "Arrays," I showed how to use arrays to store associative data. In this chapter you will see how to use the
Dictionary data types to store and retrieve this kind of information and explore other situations where
Objects are useful.
Object is found at the root of the type hierarchy of all classes. Simple classes like
Object directly; classes like
Sprite descend from
Object. In other words, every object in the ActionScript 3.0 world is an
Object class by itself doesn't do much and would hardly merit its own chapter but for the interesting property that the
Object class is one of the few classes that is dynamic.
Dynamic classes can be extended at runtime with new properties and methods. This means you can take the data and operations that define an object and rename them, rewire them, or add to them while the program is running. Programming with dynamic classes is usually a poor choice. If you were programming a dinner set as a dynamic class, some code you don't control could overwrite your
saltShaker property to dispense habanero peppers, ruining a perfectly good meal. A chaotic world like that is no world to live in, so every class I write in this book ...