Actionscript 3 Padding Component – Applying the Decorator Pattern

May 4, 2009

PaddingDecorator is an Actionscript 3 component (extends UIComponent) that uses the Decorator Design Pattern to add padding to DisplayObjects.

Padding Decorator - Class Diagram

You can download the component here.

Usage:

import org.mi.layout.decorators.PaddingDecorator;

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;

addChild(padding);