YUI AS Component Documentation | All Packages | All Classes | Index | Frames No Frames |
Class LayoutContainer

Package | com.yahoo.astra.layout
Class | public class LayoutContainer
Inheritance | LayoutContainer flash.display.Sprite
Implements | ILayoutContainer

Children of this display object are subject to being positioned, and possibly resized, based on a specified layout algorithm. LayoutContainer integrates with LayoutManager to refresh its the layout of its children when properties on the container itself change or when one of its children dispatches a registered invalidating event. This is the default implementation of ILayoutContainer.

Example
The following code demonstrates the usage of LayoutContainer:

      // create an instance of a layout mode
      var mode:ILayoutMode = new BoxLayout();
      mode.direction = "horizontal";
      mode.horizontalGap = 10;

      // one may pass the mode to the constructor or the layoutMode property.
      // note: by default, a LayoutContainer will automatically determine
      // its size based on its content.
      var container:LayoutContainer = new LayoutContainer( mode );
      this.addChild(container);

      for( var i:int = 0; i < 5; i++ )
      {
          var square:Shape = new Shape();
          square.graphics.beginFill(0xcccccc);
          square.graphics.drawRect(0, 0, 25, 25);
          square.graphics.endFill();
          container.addChild(square);
      }

Important Note: LayoutContainer leaves certain functionality to the implementor to complete. No scrollbars or other user interface controls will appear when the contents are larger than the LayoutContainer's dimensions.

This limitation is deliberate and by design. The philosophy behind this choice centers on allowing an ActionScript developer to use these classes as a basis for implementing layout controls for nearly any user interface library available for Flash Player.

For a reference implementation of full-featured UI controls that implement masking and scrolling, please take a look at the Layout Containers available in the Yahoo! Astra Components for Flash CS3.

See also

LayoutManager
ILayoutContainer
Available Layout Modes (com.yahoo.astra.layout.modes)

Public Properties

| Property | Defined by
--- | --- | ---
|  | autoMask : Boolean If true, the conent will automatically update the scrollRect to fit the dimensions. | LayoutContainer
|  | contentHeight : Number [read-only] The height of the content displayed by the layout container. | LayoutContainer
|  | contentWidth : Number [read-only] The width of the content displayed by the layout container. | LayoutContainer
|  | layoutMode : ILayoutMode The layout algorithm used to display children of the layout container. | LayoutContainer

Public Methods

| Method | Defined by
--- | --- | ---
|  | LayoutContainer(mode:ILayoutMode = null) Constructor. | LayoutContainer
|  | invalidateLayout():void Informs the layout container that it should update the layout of its children. | LayoutContainer
|  | validateLayout():void Immediately updates the layout of the container's children. | LayoutContainer

Events

| Event | Summary | Defined by
--- | --- | --- | ---
|  | layoutChange | Dispatched when this container's layout changes. | LayoutContainer

Property detail

autoMask | property

`autoMask:Boolean` [read-write]

If true, the conent will automatically update the scrollRect to fit the dimensions. Uses explicit dimensions if width or height is set by the developer. Otherwise, uses the content dimensions. If false, it is up to the implementor to set the mask or scrollRect.

Implementation
`public function get autoMask():Boolean`
`public function set autoMask(value:Boolean):void`

contentHeight | property |

`contentHeight:Number` [read-only]

The height of the content displayed by the layout container.

Implementation
`public function get contentHeight():Number`

contentWidth | property |

`contentWidth:Number` [read-only]

The width of the content displayed by the layout container.

Implementation
`public function get contentWidth():Number`

layoutMode | property |

`layoutMode:ILayoutMode` [read-write]

The layout algorithm used to display children of the layout container.

Implementation
`public function get layoutMode():ILayoutMode`
`public function set layoutMode(value:ILayoutMode):void`
Constructor detail

LayoutContainer | () | constructor

`public function LayoutContainer(mode:ILayoutMode = null)`

Constructor.

Parameters

| `mode:ILayoutMode` (default = `null`)`` — The ILayoutMode implementation to use.

Method detail

invalidateLayout | () | method

`public function invalidateLayout():void`

Informs the layout container that it should update the layout of its children.

validateLayout | () | method |

`public function validateLayout():void`

Immediately updates the layout of the container's children.

Event detail

layoutChange | event

Event object type: `com.yahoo.astra.layout.events.LayoutEvent`
LayoutEvent.type property = `com.yahoo.astra.layout.events.LayoutEvent.LAYOUT_CHANGE`

Dispatched when this container's layout changes.

The `LayoutEvent.LAYOUT_CHANGE` event type constant indicates that the layout of an ILayoutContainer needs to be redrawn.