Michael Baczynski has developed a package of common data structures useful for game development. However, their utility far exceeds game development and will come in very handy for application development based on design patterns. I came across this resource while searching for an AS3 hash table implementation. In addition to hash tables, the package contains ready to use structures for multi-dimensional arrays, queues, stacks, trees, heaps, graphs and vectors. The API docs are available as well.
Author Archive for Chandima
This is part 1 of a two part composite pattern example implemented in ActionScript 3. The composite pattern comes in handy to develop complex structures consisting of simpler parts or components. The components can be primitive objects or they can be containers that hold other components. An example will help explain this better. Think of a house as a composite object. A house consists of a roof and several rooms (living spaces). Each room can contain windows, chairs etc. The house and rooms are composite objects as they contain other components. However, we can consider the roof, windows, beds and chairs as primitive objects. The composite pattern makes building, accessing, and manipulating composite structures simple by enabling the client to treat both composite objects (that contain other objects) and components (primitive objects) the same way through a common interface.
The following example develops a book in Flash. A book is a composite object as it contains several pages. This is by no means a functional book, but a conceptual example to illustrate the utility of the composite pattern. One of the big advantages of design patterns is extensibility: allowing the application to expand and add new features without breaking existing functionality. We will extend this example in part 2 by adding composite pages that can contain text and images.
Continue reading ‘Composite Pattern: Book (Part 1)’
Doug Crockford, Chief JavaScript Architect at Yahoo, did an excellent four part video series (each about 30 minutes long). Doug has a nice presentation style and covers most of the foundational elements of the language. There is a lot to learn here for ActionScript 3.0 programmers because of the common ECMA Script foundation in both languages.
Continue reading ‘JavaScript lectures’
Roger Braunstein has posted an excellent E4X primer at http://mimswright.com/blog/?p=141. He addresses a lot of the gotchas like setting the default namespace before parsing an XML node - something that drove me up the wall before I figured it out.
In AS2, declaring a constructor as private in a class prevented it from being instantiated. Unlike AS2, constructor methods cannot be declared as private in ActionScript 3.0. This killed the simple runtime check for abstract class instantation. Sho Kuwamoto, Senior Director of Engineering at Adobe describes the thought process behind the omission of private constructors in AS3.
A more creative approach to implementing abstract classes is necessary in AS3. The issue of preventing instantiation of abstract classes in AS3 has been looked into very throughly by several developers such as Tink and Mims Wright. The solution is quite simple, but how do we make sure that abstract methods have been implemented in subclasses as well? This post describes one solution (Mims has another) to this issue using the concept of type introspection in ActionScript 3.0.
Continue reading ‘Runtime Checks for Abstract Classes and Methods in ActionScript 3.0′

Recent Comments