May 4, 2009
PaddingDecorator is an Actionscript 3 component (extends UIComponent) that uses the Decorator Design Pattern to add padding to DisplayObjects.
You can download the component here.
var mc:MovieClip = new MovieClip();
var padding:PaddingDecorator = new PaddingDecorator();
padding.left = 10;
padding.right = 20;
padding.bottom = 30;
padding.top = 50;
padding.component = mc;
February 2, 2009
DUH! Hehe. Thanks for the comments and for clearing this one for me. That’s so obvious I don’t know how I missed it. Event.ADDED, Event.REMOVED and the event propagation mechanism takes care of this problem. Closing this one up.
Read the rest of this entry »
February 2, 2009
Ever since Flex came out people have been after similar functionality for Flash. There aren’t many options out there, but a few worth mentioning are http://www.soundstep.com/blog/downloads/baseui/ and http://www.nbilyk.com/flash-layout-manager. After studying these (great) diferent approaches, I decided to give it a try and build my own version, similarities not a coincidence.
LayoutManager and LayoutElement
LayoutElement extends a DisplayObject’s size and positioning properties. Both size and position can be specified in pixels or percentage of a container. LayoutManager manages LayoutElements and updates them as necessary.
LayoutContainer extends Flash’s UIComponent and works much like ScrollPane, except it’s content can be added/removed directly just like any other DisplayObjectContainer.
Layouts Containers, such as Canvas, HBox and VBox, extends from the LayoutContainer class and add LayoutManager and LayoutElement functionality.