Actionscript 3.0 Layout Framework
October 26th, 2008 • AS3-Layout-Framework, Actionscript 3.0, Design Patterns
During the last weeks I worked on an layout framework for actionscript 3.0 in my free time. I thought I would get some inspiration from the JAVA layout framework, and yes I got it.
Unfortunately the layout framework itself was overengineered and was not totally fulfilling my conceivabilities.
I just wanted a layout framework which is easy to extend, lightweight and fast with interfaces flexible enough for be used in other solutions( f.e. drag and drop).
The core concept of this layout framework is basically very easy. The components are composite-based and the algorithms for layouting are encapsulated in strategies[GHJV95].
For easy usage I also wrote a basic UILayoutComponent/UILayoutContainer dependend to the display-list (extends Sprite).
To make these components more powerful, ILayoutComponent extends ILayoutObservable, an interface that provides functionality for other objects to listen to specific layout events (f.e. update or cropping of the layout bounds).
The encapsulation of the layout algorithms ease the use of custom layouts a lot. A concrete implementation just have to implement the ILayout interface and a new UILayoutContainer will be parameterized with an instance of this strategy at construction time (it is also possible to change layout strategies at runtime set layout(layout: ILayout)).
The following uml-diagram shows the core architecture of the layout framework:

The layout framework can be found in the addicted2flash library.
References:
[GHJV95] E. Gamma, R. Helm, R. Johnson, and J. Vlissides, Design Patterns – Elements of Reusable Object-Oriented Software, Addison-Wesley, 1995
Recent Comments