You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/08/12 00:36:59 UTC

[royale-asjs] 03/03: try bringing over Spark layout subsystem except for any 3D/Matrix stuff. Drag/Drop is also commented out for now as is some Baseline calculations

This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch feature/MXRoyale
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 0667cac560a49967ee614443f00e712d3d0c5787
Author: Alex Harui <ah...@apache.org>
AuthorDate: Sat Aug 11 17:36:41 2018 -0700

    try bringing over Spark layout subsystem except for any 3D/Matrix stuff.  Drag/Drop is also commented out for now as is some Baseline calculations
---
 .../MXRoyale/src/main/royale/MXRoyaleClasses.as    |    1 +
 .../src/main/royale/mx/core/ILayoutElement.as      |  845 ++++
 .../src/main/royale/mx/core/IVisualElement.as      |    2 +-
 .../mx/core/LayoutElementUIComponentUtils.as       |  588 +++
 .../src/main/royale/mx/core/UIComponent.as         |  291 +-
 .../spark/components/supportClasses/GroupBase.as   |   64 +-
 .../spark/components/supportClasses/TextBase.as    |  142 +-
 .../src/main/royale/spark/core/NavigationUnit.as   |  181 +
 .../main/royale/spark/layouts/HorizontalAlign.as   |   94 +
 .../main/royale/spark/layouts/HorizontalLayout.as  |  382 +-
 .../src/main/royale/spark/layouts/TileLayout.as    | 5026 ++++++++++----------
 .../src/main/royale/spark/layouts/VerticalAlign.as |  104 +
 .../main/royale/spark/layouts/VerticalLayout.as    | 4773 +++++++++----------
 .../royale/spark/layouts/supportClasses/Block.as   |   52 +
 .../spark/layouts/supportClasses/DropLocation.as   |   90 +
 .../spark/layouts/supportClasses/LayoutBase.as     | 2086 ++++++++
 .../layouts/supportClasses/LayoutElementHelper.as  |  156 +
 .../layouts/supportClasses/LinearLayoutVector.as   | 1169 +++++
 18 files changed, 10853 insertions(+), 5193 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
index 44f2ba3..e8f89a2 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
@@ -38,6 +38,7 @@ internal class MXRoyaleClasses
 	import mx.graphics.IFill; IFill;
 	import mx.core.EventPriority; EventPriority;
 	import mx.core.IFactory; IFactory;
+    import mx.core.ILayoutElement; ILayoutElement;
 	import mx.collections.CursorBookmark; CursorBookmark;
 	import mx.collections.ICollectionView; ICollectionView;
 	import mx.collections.IViewCursor; IViewCursor;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/ILayoutElement.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/ILayoutElement.as
new file mode 100644
index 0000000..786b73b
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/ILayoutElement.as
@@ -0,0 +1,845 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.core
+{
+
+import org.apache.royale.events.IEventDispatcher;
+//import flash.geom.Matrix;
+//import flash.geom.Matrix3D;
+//import flash.geom.Vector3D;
+
+/**
+ *  The ILayoutElement interface is used primarily by the layout classes to query,
+ *  size and position the elements of GroupBase containers.
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+public interface ILayoutElement extends IEventDispatcher
+{
+/**
+     *  The horizontal distance in pixels from the left edge of the component to the
+     *  anchor target's left edge.
+     *
+     *  <p>By default the anchor target is the container's content area. In layouts
+     *  with advanced constraints, the target can be a constraint column.</p>
+     *
+     *  <p>Setting the property to a number or to a numerical string like "10"
+     *  specifies use of the default anchor target.</p>
+     *
+     *  <p>To specify an anchor target, set the property value to a string in the format
+     *  "anchorTargetName:value". For example, "col1:10".</p>
+     *
+     *  @default null
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function get left():Object;
+    
+    /**
+     *  @private
+     */
+    function set left(value:Object):void;
+
+    /**
+     *  The horizontal distance in pixels from the right edge of the component to the
+     *  anchor target's right edge.
+     *
+     *  <p>By default the anchor target is the container's content area. In layouts
+     *  with advanced constraints, the target can be a constraint column.</p>
+     *
+     *  <p>Setting the property to a number or to a numerical string like "10"
+     *  specifies use of the default anchor target.</p>
+     *
+     *  <p>To specify an anchor target, set the property value to a string in the format
+     *  "anchorTargetName:value". For example, "col1:10".</p>
+     *
+     *  @default null
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function get right():Object;
+    
+    /**
+     *  @private
+     */
+    function set right(value:Object):void;
+
+    /**
+     *  The vertical distance in pixels from the top edge of the component to the
+     *  anchor target's top edge.
+     *
+     *  <p>By default the anchor target is the container's content area. In layouts
+     *  with advanced constraints, the target can be a constraint row.</p>
+     *
+     *  <p>Setting the property to a number or to a numerical string like "10"
+     *  specifies use of the default anchor target.</p>
+     *
+     *  <p>To specify an anchor target, set the property value to a string in the format
+     *  "anchorTargetName:value". For example, "row1:10".</p>
+     *
+     *  @default null
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function get top():Object;
+    
+    /**
+     *  @private
+     */
+    function set top(value:Object):void;
+
+    /**
+     *  The vertical distance in pixels from the bottom edge of the component to the
+     *  anchor target's bottom edge.
+     *
+     *  <p>By default the anchor target is the container's content area. In layouts
+     *  with advanced constraints, the target can be a constraint row.</p>
+     *
+     *  <p>Setting the property to a number or to a numerical string like "10"
+     *  specifies use of the default anchor target.</p>
+     *
+     *  <p>To specify an anchor target, set the property value to a string in the format:
+     *  "anchorTargetName:value". For example, "row1:10".</p>
+     *
+     *  @default null
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function get bottom():Object;
+    
+    /**
+     *  @private
+     */
+    function set bottom(value:Object):void;
+
+    /**
+     *  The horizontal distance in pixels from the center of the component to the
+     *  center of the anchor target's content area.
+     *
+     *  <p>The default anchor target is the container itself.</p>
+     *
+     *  <p>In layouts with advanced constraints, the anchor target can be a constraint column.
+     *  Then the content area is the space between the preceding column
+     *  (or container side) and the target column.</p>
+     *
+     *  <p>Setting the property to a number or to a numerical string like "10"
+     *  specifies use of the default anchor target.</p>
+     *
+     *  <p>To specify an anchor target, set the property value to a string in the format
+     *  "constraintColumnId:value". For example, "col1:10".</p>
+     *
+     *  @default null
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function get horizontalCenter():Object;
+    
+    /**
+     *  @private
+     */
+    function set horizontalCenter(value:Object):void;
+
+    /**
+     *  The vertical distance in pixels from the center of the component to the
+     *  center of the anchor target's content area.
+     *
+     *  <p>The default anchor target is the container itself.</p>
+     *
+     *  <p>In layouts with advanced constraints, the anchor target can be a constraint row.
+     *  Then the content area is the space between the preceding row
+     *  (or container side) and the target row.</p>
+     *
+     *  <p>Setting the property to a number or to a numerical string like "10"
+     *  specifies use of the default anchor target.</p>
+     *
+     *  <p>To specify an anchor target, set the property value to a string in the format
+     *  "constraintColumnId:value". For example, "row1:10".</p>
+     *
+     *  @default null
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function get verticalCenter():Object;
+    
+    /**
+     *  @private
+     */
+    function set verticalCenter(value:Object):void;
+
+    /**
+     *  The vertical distance in pixels from the anchor target to
+     *  the control's baseline position.
+     *
+     *  <p>By default the anchor target is the top edge of the container's
+     *  content area. In layouts with advanced constraints, the target can be
+     *  a constraint row.</p>
+     *
+     *  <p>Setting the property to a number or to a numerical string like "10"
+     *  specifies use of the default anchor target.</p>
+     *
+     *  <p>To specify an anchor target, set the property value to a string in the format:
+     *  "anchorTargetName:value". For example, "row1:10".</p>
+     *
+     *  @default null
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+    function get baseline():Object;
+     */
+    
+    /**
+     *  @private
+    function set baseline(value:Object):void;
+     */
+
+    /**
+     *  The y-coordinate of the baseline
+     *  of the first line of text of the component.
+     *
+     *  <p>This property is used to implement
+     *  the <code>baseline</code> constraint style.
+     *  It is also used to align the label of a FormItem
+     *  with the controls in the FormItem.</p>
+     *
+     *  <p>Each component should override this property.</p>
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function get baselinePosition():Number;
+    
+    /**
+     *  Specifies the width of a component as a percentage
+     *  of its parent's size. Allowed values are 0-100.
+     *  Setting the <code>width</code> or <code>explicitWidth</code> properties
+     *  resets this property to NaN.
+     *
+     *  <p>This property returns a numeric value only if the property was
+     *  previously set; it does not reflect the exact size of the component
+     *  in percent.</p>
+     *
+     *  @default NaN
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function get percentWidth():Number;
+    
+    /**
+     *  @private
+     */
+    function set percentWidth(value:Number):void;
+
+    /**
+     *  Specifies the height of a component as a percentage
+     *  of its parent's size. Allowed values are 0-100.
+     *  Setting the <code>height</code> or <code>explicitHeight</code> properties
+     *  resets this property to NaN.
+     *
+     *  <p>This property returns a numeric value only if the property was
+     *  previously set; it does not reflect the exact size of the component
+     *  in percent.</p>
+     *
+     *  @default NaN
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function get percentHeight():Number;
+    
+    /**
+     *  @private
+     */
+    function set percentHeight(value:Number):void;
+ 
+    /**
+     *  @copy mx.core.UIComponent#includeInLayout
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */   
+    function get includeInLayout():Boolean;
+    
+    /**
+     *  @private
+     */
+    function set includeInLayout(value:Boolean):void;
+    
+    /**
+     *  Returns the element's preferred width.   
+     * 
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is <code>true</code>,
+     *  the method returns the element's bounding box width.  
+     *  The bounding box is in the element's parent
+     *  coordinate space and is calculated from  the element's preferred size and
+     *  layout transform matrix.
+     *
+     *  @return Returns the element's preferred width.  Preferred width is
+     *  usually based on the default element size and any explicit overrides.
+     *  For UIComponent this is the same value as returned by 
+     *  the <code>getExplicitOrMeasuredWidth()</code> method.
+     * 
+     *  @see #getPreferredBoundsHeight()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function getPreferredBoundsWidth(postLayoutTransform:Boolean = true):Number;
+
+    /**
+     *  Returns the element's preferred height.  
+     *
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is <code>true</code>,
+     *  the method returns the element's bounding box height.  
+     *  The bounding box is in the element's parent
+     *  coordinate space and is calculated from  the element's preferred size and
+     *  layout transform matrix.
+     *
+     *  @return Returns the element's preferred height.  Preferred height is
+     *  usually based on the default element size and any explicit overrides.
+     *  For UIComponent this is the same value as returned by 
+     *  the <code>getExplicitOrMeasuredHeight()</code> method.
+     *
+     *  @see #getPreferredBoundsWidth()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function getPreferredBoundsHeight(postLayoutTransform:Boolean = true):Number;
+
+    /**
+     *  Returns the element's minimum width.
+     * 
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is <code>true</code>,
+     *  the method returns the element's bounding box width. 
+     *  The bounding box is in the element's parent
+     *  coordinate space and is calculated from the element's minimum size and
+     *  layout transform matrix.
+     *
+     *  @return The element's maximum width.
+     *
+     *  @see #getMinBoundsHeight()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function getMinBoundsWidth(postLayoutTransform:Boolean = true):Number;
+
+    /**
+     *  Returns the element's minimum height.
+     * 
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is <code>true</code>,
+     *  the method returns the element's bounding box height. 
+     *  The bounding box is in the element's parent
+     *  coordinate space and is calculated from the element's minimum size and
+     *  layout transform matrix.
+     *
+     *  @return The element's maximum height.
+     *
+     *  @see #getMinBoundsWidth()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function getMinBoundsHeight(postLayoutTransform:Boolean = true):Number;
+
+    /**
+     *  Returns the element's maximum width.
+     * 
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is true, the method returns
+     *  the element's bounding box width. The bounding box is in the element's parent
+     *  coordinate space and is calculated from the element's maximum size and
+     *  layout transform matrix.
+     *
+     *  @return The element's maximum width.
+     *
+     *  @see #getMaxBoundsHeight()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function getMaxBoundsWidth(postLayoutTransform:Boolean = true):Number;
+
+    /**
+     *  Returns the element's maximum height.
+     * 
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is true, the method returns
+     *  the element's bounding box height. The bounding box is in the element's parent
+     *  coordinate space and is calculated from the element's maximum size and
+     *  layout transform matrix.
+     *
+     *  @return The element's maximum height.
+     *
+     *  @see #getMaxBoundsWidth()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function getMaxBoundsHeight(postLayoutTransform:Boolean = true):Number;
+    
+    /**
+     *  Returns the x coordinate of the element's bounds at the specified element size.
+     * 
+     *  <p>This method is typically used by layouts during a call to the 
+     *  <code>measure()</code> method to predict what
+     *  the element position will be, if the element is resized to particular dimensions.</p>
+     * 
+     *  @param width The element's bounds width, or NaN to use the preferred width.
+     *  @param height The element's bounds height, or NaN to use the preferred height.
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is true, the method returns
+     *  x coordinate of the element's bounding box top-left corner.
+     *  The bounding box is in element's parent coordinate space and is calculated
+     *  from the specified bounds size, layout position and layout transform matrix.
+     *
+     *  @return The x coordinate of the element's bounds at the specified element size.
+     *
+     *  @see #setLayoutBoundsSize()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function getBoundsXAtSize(width:Number, height:Number, postLayoutTransform:Boolean = true):Number;
+
+    /**
+     *  Returns the y coordinate of the element's bounds at the specified element size.
+     * 
+     *  This method is typically used by layouts during a call to 
+     *  the <code>measure()</code> to predict what
+     *  the element position will be, if the element is resized to particular dimensions.
+     * 
+     *  @param width The element's bounds width, or NaN to use the preferred width.
+     *  @param height The element's bounds height, or NaN to use the preferred height.
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is true, the method returns
+     *  the y coordinate of the element's bounding box top-left corner.
+     *  The bounding box is in element's parent coordinate space and is calculated
+     *  from the specified bounds size, layout position and layout transform matrix.
+     *  
+     *  @return The y coordinate of the element's bounds at the specified element size.
+     *
+     *  @see #setLayoutBoundsSize()
+     *  @see #getLayoutBoundsY()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function getBoundsYAtSize(width:Number, height:Number, postLayoutTransform:Boolean = true):Number;
+    
+    /**
+     *  Returns the element's layout width. This is the size that the element uses
+     *  to draw on screen.
+     *
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is true, the method returns
+     *  the element's bounding box width. The bounding box is in element's parent
+     *  coordinate space and is calculated from the element's layout size and
+     *  layout transform matrix.
+     *  
+     *  @return The element's layout width.
+     *
+     *  @see #getLayoutBoundsHeight()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function getLayoutBoundsWidth(postLayoutTransform:Boolean = true):Number;
+
+    /**
+     *  Returns the element's layout height. This is the size that the element uses
+     *  to draw on screen.
+     *
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is true, the method returns
+     *  the element's bounding box width. The bounding box is in the element's parent
+     *  coordinate space and is calculated from the element's layout size and
+     *  layout transform matrix.
+     *  
+     *  @return The element's layout height.
+     *
+     *  @see #getLayoutBoundsWidth()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function getLayoutBoundsHeight(postLayoutTransform:Boolean = true):Number;
+    
+    /**
+     *  Returns the x coordinate that the element uses to draw on screen.
+     *
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is true, the method returns
+     *  x coordinate of the element's bounding box top-left corner.
+     *  The bounding box is in the element's parent coordinate space and is calculated
+     *  from the element's layout size, layout position and layout transform matrix.
+     * 
+     *  @return The x coordinate that the element uses to draw on screen.
+     * 
+     *  @see #getLayoutBoundsY()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function getLayoutBoundsX(postLayoutTransform:Boolean = true):Number;
+
+    /**
+     *  Returns the y coordinate that the element uses to draw on screen.
+     *
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is true, the method returns
+     *  y coordinate of the element's bounding box top-left corner.
+     *  The bounding box is in the element's parent coordinate space and is calculated
+     *  from the element's layout size, layout position, and layout transform matrix.
+     * 
+     *  @return The y coordinate that the element uses to draw on screen.
+     * 
+     *  @see #getLayoutBoundsX()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function getLayoutBoundsY(postLayoutTransform:Boolean = true):Number;
+
+    /**
+     *  Sets the coordinates that the element uses to draw on screen.
+     *
+     *  <p>Note that calls to the <code>setLayoutBoundSize()</code> method can affect the layout position, so 
+     *  call <code>setLayoutBoundPosition()</code> after calling <code>setLayoutBoundSize()</code>.</p>
+     *
+     *  @param x The x-coordinate of the top-left corner of the bounding box. 
+     *
+     *  @param y The y-coordinate of the top-left corner of the bounding box.
+     *
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is <code>true</code>, 
+     *  the element is positioned in such a way that the top-left corner of its bounding box is (x, y).
+     *  The bounding box is in the element's parent coordinate space and is calculated
+     *  from the element's layout size, layout position and layout transform matrix.
+     *
+     *  @see #setLayoutBoundsSize()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function setLayoutBoundsPosition(x:Number, y:Number, postLayoutTransform:Boolean = true):void;
+
+    /**
+     *  Sets the layout size of the element.  
+     *  This is the size that the element uses to draw on screen.
+     *  
+     *  <p>If the <code>width</code> and/or <code>height</code> parameters are left unspecified (NaN),
+     *  Flex sets the element's layout size to its preferred width and/or preferred height.</p>
+     * 
+     *  <p>Note that calls to the <code>setLayoutBoundSize()</code> method can affect the layout position, so 
+     *  call <code>setLayoutBoundPosition()</code> after calling <code>setLayoutBoundSize()</code>.</p>
+     *
+     *  @param width The element's layout width.
+     *
+     *  @param height The element's layout height.
+     *
+     *  @param postLayoutTransform When <code>postLayoutTransform</code> is true, the specified sizes
+     *  are those of the element's bounding box.
+     *  The bounding box is in the element's parent coordinate space and is calculated
+     *  from the element's layout size, layout position, and layout transform matrix.
+     * 
+     *  @see #setLayoutBoundsPosition()
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    function setLayoutBoundsSize(width:Number,
+                                 height:Number,
+                                 postLayoutTransform:Boolean = true):void;
+
+    /**
+     *  Returns the transform matrix that is used to calculate the component's
+     *  layout relative to its siblings.
+     *
+     *  <p>This matrix is typically defined by the
+     *  component's 2D properties such as <code>x</code>, <code>y</code>,
+     *  <code>rotation</code>, <code>scaleX</code>, <code>scaleY</code>,
+     *  <code>transformX</code>, and <code>transformY</code>.
+     *  Some components may have additional transform properties that
+     *  are applied on top of the layout matrix to determine the final,
+     *  computed matrix.  For example <code>UIComponent</code>
+     *  defines the <code>offsets</code> property.</p>
+     *  
+     *  @return The layout transform Matrix for this element.
+     *  Do not directly modify the return value; call the <code>setLayoutMatrix()</code> method instead.
+     * 
+     *  @see #setLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  @see #setLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+    function getLayoutMatrix():Matrix;
+     */
+
+    /**
+     *  Sets the transform Matrix that is used to calculate the component's layout
+     *  size and position relative to its siblings.
+     *
+     *  <p>The matrix is typically defined by the
+     *  component's 2D properties such as <code>x</code>, <code>y</code>,
+     *  <code>rotation</code>, <code>scaleX</code>, <code>scaleY</code>,
+     *  <code>transformX</code>, and <code>transformY</code>.
+     *  Some components may have additional transform properties that
+     *  are applied on top of the layout matrix to determine the final,
+     *  computed matrix.  For example <code>UIComponent</code>
+     *  defines the <code>offsets</code>.</p>
+     *  
+     *  <p>Note that layout Matrix is factored in the <code>getPreferredSize()</code>,
+     *  <code>getMinSize()</code>, <code>getMaxSize()</code>, <code>getLayoutSize()</code> 
+     *  methods when computed in parent coordinates
+     *  as well as in <code>getLayoutPosition()</code> in both parent and child coordinates.
+     *  Layouts that calculate the transform matrix explicitly typically call
+     *  this method and work with sizes in child coordinates.
+     *  Layouts calling this method pass <code>false</code>
+     *  to the <code>invalidateLayout()</code> method so that a subsequent layout pass is not
+     *  triggered.</p>
+     *
+     *  @param Matrix The matrix.
+     *
+     *  @param invalidateLayout <code>true</code> to cause the parent container 
+     *  to re-layout its children. You typically pass <code>true</code>
+     *  to the <code>invalidateLayout()</code> method.
+     * 
+     *  @see #getLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  @see #setLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+    function setLayoutMatrix(value:Matrix, invalidateLayout:Boolean):void;
+     */
+    
+    /**
+     *  Contains <code>true</code> if the element has 3D Matrix.
+     *
+     *  <p>Use <code>hasLayoutMatrix3D</code> instead of calling and examining the
+     *  return value of <code>getLayoutMatrix3D()</code> because that method returns a valid
+     *  matrix even when the element is in 2D.</p>
+     * 
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+    function get hasLayoutMatrix3D():Boolean;
+     */
+
+    /**
+     *  Returns the layout transform Matrix3D for this element.
+     * 
+     *  <p>This matrix is typically defined by the
+     *  component's transform properties such as <code>x</code>, <code>y</code>, 
+     *  <code>z</code>, <code>rotationX</code>, <code>rotationY</code>,
+     *  <code>rotationZ</code>, <code>scaleX</code>, <code>scaleY</code>,
+     *  <code>scaleZ</code>, <code>transformX</code>, and <code>transformY</code>.
+     *  Some components may have additional transform properties that
+     *  are applied on top of the layout matrix to determine the final,
+     *  computed matrix.  For example <code>UIComponent</code>
+     *  defines the <code>offsets</code> property.</p>
+     * 
+     *  @return The layout transform Matrix3D for this element.
+     *  Do not directly modify the return value but call the <code>setLayoutMatrix()</code> method instead.
+     *  
+     *  @see #getLayoutMatrix()
+     *  @see #setLayoutMatrix()
+     *  @see #setLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+    function getLayoutMatrix3D():Matrix3D;
+     */
+
+    /**
+     *  Sets the transform Matrix3D that is used to calculate the component's layout
+     *  size and position relative to its siblings.
+     *
+     *  <p>This matrix is typically defined by the
+     *  component's transform properties such as <code>x</code>, <code>y</code>, 
+     *  <code>z</code>, <code>rotationX</code>, <code>rotationY</code>,
+     *  <code>rotationZ</code>, <code>scaleX</code>, <code>scaleY</code>,
+     *  <code>scaleZ</code>, <code>transformX</code>, and <code>transformY</code>.
+     *  Some components may have additional transform properties that
+     *  are applied on top of the layout matrix to determine the final,
+     *  computed matrix.  For example <code>UIComponent</code>
+     *  defines the <code>offsets</code> property.</p>
+     *  
+     *  <p>Note that layout Matrix3D is factored in the <code>getPreferredSize()</code>,
+     *  <code>getMinSize()</code>, <code>getMaxSize()</code>, <code>getLayoutSize()</code> 
+     *  when computed in parent coordinates
+     *  as well as in <code>getLayoutPosition()</code> in both parent and child coordinates.
+     *  Layouts that calculate the transform matrix explicitly typically call
+     *  this method and work with sizes in child coordinates.
+     *  Layouts calling this method pass <code>false</code>
+     *  to the <code>invalidateLayout()</code> method so that a subsequent layout pass is not
+     *  triggered.</p>
+     *
+     *  @param Matrix The matrix.
+     *
+     *  @param invalidateLayout <code>true</code> to cause the parent container 
+     *  to re-layout its children. You typically pass <code>true</code>
+     *  to the <code>invalidateLayout()</code> method.
+     * 
+     *  @see #getLayoutMatrix()
+     *  @see #setLayoutMatrix()
+     *  @see #getLayoutMatrix3D()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+    function setLayoutMatrix3D(value:Matrix3D, invalidateLayout:Boolean):void;
+     */
+
+    /**
+     *  A utility method to update the rotation, scale, and translation of the 
+     *  transform while keeping a particular point, specified in the component's 
+     *  own coordinate space, fixed in the parent's coordinate space.  
+     *  This function will assign the rotation, scale, and translation values 
+     *  provided, then update the x/y/z properties as necessary to keep 
+     *  the transform center fixed.
+     *
+     *  @param transformCenter The point, in the component's own coordinates, 
+     *  to keep fixed relative to its parent.
+     *
+     *  @param scale The new values for the scale of the transform.
+     *
+     *  @param rotation the new values for the rotation of the transform
+     *
+     *  @param translation The new values for the translation of the transform.
+     *
+     *  @param postLayoutScale The new values for the post-layout scale 
+     *  of the transform.
+     *
+     *  @param postLayoutRotation The new values for the post-layout rotation 
+     *  of the transform.
+     *
+     *  @param postLayoutTranslation The new values for the post-layout translation 
+     *  of the transform.
+     *
+     *  @param invalidateLayout If <code>true</code>, the parent container size and display are
+     *  invalidated. Layouts calling this method pass <code>false</code>
+     *  so that a subsequent layout pass is not triggered.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+    function transformAround(transformCenter:Vector3D,
+                                    scale:Vector3D = null,
+                                    rotation:Vector3D = null,
+                                    translation:Vector3D = null,
+                                    postLayoutScale:Vector3D = null,
+                                    postLayoutRotation:Vector3D = null,
+                                    postLayoutTranslation:Vector3D = null,
+                                    invalidateLayout:Boolean = true):void;    
+     */
+}
+
+}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/IVisualElement.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/IVisualElement.as
index ba96428..301074e 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/IVisualElement.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/IVisualElement.as
@@ -29,7 +29,7 @@ import org.apache.royale.core.IParent;
  *  @playerversion AIR 1.5
  *  @productversion Flex 4
  */
-public interface IVisualElement /* extends ILayoutElement, ILayoutDirectionElement*/
+public interface IVisualElement extends ILayoutElement/*, ILayoutDirectionElement*/
 {
 
     /**
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/LayoutElementUIComponentUtils.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/LayoutElementUIComponentUtils.as
new file mode 100644
index 0000000..4a42761
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/LayoutElementUIComponentUtils.as
@@ -0,0 +1,588 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package mx.core
+{
+//import flash.geom.Matrix;
+//import flash.geom.Matrix3D;
+import org.apache.royale.geom.Point;
+
+//import mx.utils.MatrixUtil;
+
+[ExcludeClass]
+
+/**
+ *  @private
+ *  Helper class to implement the ILayoutElement interface for IUIComponent
+ *  classes.
+ */
+public class LayoutElementUIComponentUtils
+{
+
+//    include "../core/Version.as";
+
+	public function LayoutElementUIComponentUtils()
+	{
+		
+	}
+    //--------------------------------------------------------------------------
+    //
+    //  Methods
+    //
+    //--------------------------------------------------------------------------
+
+    // When changing these constants, make sure you change
+    // the constants with the same name in UIComponent    
+    private static const DEFAULT_MAX_WIDTH:Number = 10000;
+    private static const DEFAULT_MAX_HEIGHT:Number = 10000;
+
+    /**
+     *  @return Returns the preferred width (untransformed) of the IUIComponent.
+     *  Takes into account measured width, explicit width, explicit min width
+     *  and explicit max width.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    private static function getPreferredUBoundsWidth(obj:IUIComponent):Number
+    {
+        // explicit trumps measured. measuredWidth should already be
+        // constraint between min & max during measure phase.
+        var result:Number = obj.getExplicitOrMeasuredWidth();
+        /*
+        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+        {
+            // We are already taking scale into account from the transform,
+            // so adjust here since IUIComponent mixes it with width/height
+            result = (obj.scaleX == 0) ? 0 : result / obj.scaleX;
+        }
+        */
+        return result;
+    }
+
+    /**
+     *  @return Returns the preferred height (untransformed) of the IUIComponent.
+     *  Takes into account measured height, explicit height, explicit min height
+     *  and explicit max height.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    private static function getPreferredUBoundsHeight(obj:IUIComponent):Number
+    {
+        // explicit trumps measured. measuredWidth should already be
+        // constraint between min & max during measure phase. 
+        var result:Number = obj.getExplicitOrMeasuredHeight();
+        /*
+        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+        {
+            // We are already taking scale into account from the transform,
+            // so adjust here since IUIComponent mixes it with width/height
+            result = (obj.scaleY == 0) ? 0 : result / obj.scaleY;
+        }
+        */
+        return result;
+    }
+    
+    private static function getMinUBoundsWidth(obj:IUIComponent):Number
+    {
+        // explicit trumps explicitMin trumps measuredMin.
+        // measuredMin is restricted by explicitMax.
+        var minWidth:Number;
+        if (!isNaN(obj.explicitMinWidth))
+        {
+            minWidth = obj.explicitMinWidth;
+        }
+        else
+        {
+            minWidth = isNaN(obj.measuredMinWidth) ? 0 : obj.measuredMinWidth;
+            if (!isNaN(obj.explicitMaxWidth))
+                minWidth = Math.min(minWidth, obj.explicitMaxWidth);
+        }
+
+        /*
+        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+        {
+            // We are already taking scale into account from the transform,
+            // so adjust here since IUIComponent mixes it with width/height
+            minWidth = (obj.scaleX == 0) ? 0 : minWidth / obj.scaleX;
+        }
+        */
+        return minWidth;
+    }
+    
+    private static function getMinUBoundsHeight(obj:IUIComponent):Number
+    {
+        // explicit trumps explicitMin trumps measuredMin.
+        // measuredMin is restricted by explicitMax.
+        var minHeight:Number;
+        if (!isNaN(obj.explicitMinHeight))
+        {
+            minHeight = obj.explicitMinHeight;
+        }
+        else
+        {
+            minHeight = isNaN(obj.measuredMinHeight) ? 0 : obj.measuredMinHeight;
+            if (!isNaN(obj.explicitMaxHeight))
+                minHeight = Math.min(minHeight, obj.explicitMaxHeight);
+        }
+
+        /*
+        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+        {
+            // We are already taking scale into account from the transform,
+            // so adjust here since IUIComponent mixes it with width/height
+            minHeight = (obj.scaleY == 0) ? 0 : minHeight / obj.scaleY;
+        }
+        */
+        return minHeight;
+    }
+    
+    private static function getMaxUBoundsWidth(obj:IUIComponent):Number
+    {
+        // explicit trumps explicitMax trumps Number.MAX_VALUE.
+        var maxWidth:Number;
+        if (!isNaN(obj.explicitMaxWidth))
+            maxWidth = obj.explicitMaxWidth;
+        else
+            maxWidth = DEFAULT_MAX_WIDTH;
+
+        /*
+        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+        {
+            // We are already taking scale into account from the transform,
+            // so adjust here since IUIComponent mixes it with width/height
+            maxWidth = (obj.scaleX == 0) ? 0 : maxWidth / obj.scaleX;
+        }
+        */
+        return maxWidth;
+    }
+    
+    private static function getMaxUBoundsHeight(obj:IUIComponent):Number
+    {
+        // explicit trumps explicitMax trumps Number.MAX_VALUE.
+        var maxHeight:Number;
+        if (!isNaN(obj.explicitMaxHeight))
+            maxHeight = obj.explicitMaxHeight;
+        else
+            maxHeight = DEFAULT_MAX_HEIGHT;
+
+        /*
+        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+        {
+            // We are already taking scale into account from the transform,
+            // so adjust here since IUIComponent mixes it with width/height
+            maxHeight = (obj.scaleY == 0) ? 0 : maxHeight / obj.scaleY;
+        }
+        */
+        return maxHeight;
+    }
+    
+
+
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public static function getPreferredBoundsWidth(obj:IUIComponent/*,transformMatrix:Matrix*/):Number
+    {
+        var width:Number = getPreferredUBoundsWidth(obj);
+
+        /*
+        if (transformMatrix)
+        {
+			width = MatrixUtil.transformSize(width, getPreferredUBoundsHeight(obj), transformMatrix).x;
+        }
+        */
+        return width;
+    }
+
+    public static function getPreferredBoundsHeight(obj:IUIComponent/*,transformMatrix:Matrix*/):Number
+    {
+        var height:Number = getPreferredUBoundsHeight(obj);
+
+        /*
+        if (transformMatrix)
+        {
+                height = MatrixUtil.transformSize(getPreferredUBoundsWidth(obj), height, transformMatrix).y;
+        }
+        */
+        return height;
+    }
+
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public static function getMinBoundsWidth(obj:IUIComponent/*, transformMatrix:Matrix*/):Number
+    {
+        var width:Number = getMinUBoundsWidth(obj);
+
+        /*
+        if (transformMatrix)
+        {
+			width = MatrixUtil.transformSize(width, getMinUBoundsHeight(obj), transformMatrix).x;
+        }
+        */
+
+        return width;
+    }
+
+    public static function getMinBoundsHeight(obj:IUIComponent/*,transformMatrix:Matrix*/):Number
+    {
+        var height:Number = getMinUBoundsHeight(obj);
+
+        /*
+        if (transformMatrix)
+        {
+			height = MatrixUtil.transformSize(getMinUBoundsWidth(obj), height, transformMatrix).y;
+        }
+        */
+
+        return height;
+    }
+
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public static function getMaxBoundsWidth(obj:IUIComponent/*, transformMatrix:Matrix*/):Number
+    {
+        var width:Number = getMaxUBoundsWidth(obj);
+        /*
+        if (transformMatrix)
+        {
+			width = MatrixUtil.transformSize(width, getMaxUBoundsHeight(obj), transformMatrix).x;
+        }
+        */
+
+        return width;
+    }
+
+    public static function getMaxBoundsHeight(obj:IUIComponent/*, transformMatrix:Matrix*/):Number
+    {
+        var height:Number = getMaxUBoundsHeight(obj);
+        /*
+        if (transformMatrix)
+        {
+			height = MatrixUtil.transformSize(getMaxUBoundsWidth(obj), height, transformMatrix).y;
+        }
+        */
+        
+        return height;
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public static function getBoundsXAtSize(obj:IUIComponent, width:Number, height:Number/*, transformMatrix:Matrix*/):Number
+    {
+        /*if (!transformMatrix)*/
+            return obj.x;
+        
+        /*
+        var fitSize:Point = MatrixUtil.fitBounds(width, height, transformMatrix,
+                                                 obj.explicitWidth,
+                                                 obj.explicitHeight,
+                                                 getPreferredUBoundsWidth(obj),
+                                                 getPreferredUBoundsHeight(obj),
+                                                 getMinUBoundsWidth(obj),
+                                                 getMinUBoundsHeight(obj),
+                                                 getMaxUBoundsWidth(obj),
+                                                 getMaxUBoundsHeight(obj));
+
+        // If we couldn't fit at all, default to the minimum size
+        if (!fitSize)
+            fitSize = new Point(getMinUBoundsWidth(obj), getMinUBoundsHeight(obj));
+            
+        var pos:Point = new Point();
+        MatrixUtil.transformBounds(fitSize.x, fitSize.y,
+                                   transformMatrix,
+                                   pos);
+        return pos.x;
+        */
+    }
+
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public static function getBoundsYAtSize(obj:IUIComponent, width:Number, height:Number/*, transformMatrix:Matrix*/):Number
+    {
+        /*if (!transformMatrix)*/
+            return obj.y;
+        
+        /*
+        var fitSize:Point = MatrixUtil.fitBounds(width, height, transformMatrix,
+                                                 obj.explicitWidth,
+                                                 obj.explicitHeight,
+                                                 getPreferredUBoundsWidth(obj),
+                                                 getPreferredUBoundsHeight(obj),
+                                                 getMinUBoundsWidth(obj),
+                                                 getMinUBoundsHeight(obj),
+                                                 getMaxUBoundsWidth(obj),
+                                                 getMaxUBoundsHeight(obj));
+
+        // If we couldn't fit at all, default to the minimum size
+        if (!fitSize)
+            fitSize = new Point(getMinUBoundsWidth(obj), getMinUBoundsHeight(obj));
+            
+        var pos:Point = new Point();
+        MatrixUtil.transformBounds(fitSize.x, fitSize.y,
+                                   transformMatrix,
+                                   pos);
+        return pos.y;
+        */
+    }
+
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public static function getLayoutBoundsWidth(obj:IUIComponent/*,transformMatrix:Matrix*/):Number
+    {
+        var width:Number = obj.width;
+        /*
+        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+        {
+            // We are already taking scale into account from the transform,
+            // so adjust here since IUIComponent mixes it with width/height
+            width = (obj.scaleX == 0) ? 0 : width / obj.scaleX;
+        }
+
+        if (transformMatrix)
+        {
+            var height:Number = obj.height;
+            if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+            {
+                // We are already taking scale into account from the transform,
+                // so adjust here since IUIComponent mixes it with width/height
+                height = (obj.scaleY == 0) ? 0 : height / obj.scaleY;
+            }
+            
+            // By default the IUIComponent's registration point is the same
+            // as its untransformed border top-left corner, which is (0,0).
+            width = MatrixUtil.transformBounds(width, height,
+                                               transformMatrix,
+                                               new Point()).x;
+        }
+        */
+        return width;
+    }
+
+    public static function getLayoutBoundsHeight(obj:IUIComponent/*,transformMatrix:Matrix*/):Number
+    {
+        var height:Number = obj.height;
+        /*
+        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+        {
+            // We are already taking scale into account from the transform,
+            // so adjust here since IUIComponent mixes it with width/height
+            height = (obj.scaleY == 0) ? 0 : height / obj.scaleY;
+        }
+
+        if (transformMatrix)
+        {
+            var width:Number = obj.width;
+            if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+            {
+                // We are already taking scale into account from the transform,
+                // so adjust here since IUIComponent mixes it with width/height
+                width = (obj.scaleX == 0) ? 0 : width / obj.scaleX;
+            }
+            
+            // By default the IUIComponent's registration point is the same
+            // as its untransformed border top-left corner, which is (0,0).
+            height = MatrixUtil.transformBounds(width, height,
+                                                transformMatrix,
+                                                new Point()).y;
+        }
+        */
+        return height;
+    }
+
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public static function getLayoutBoundsX(obj:IUIComponent/*,transformMatrix:Matrix*/):Number
+    {
+        /*if (transformMatrix == null)*/
+            return obj.x;
+
+
+        /*
+        var width:Number = obj.width;
+        var height:Number = obj.height;
+
+        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+        {
+            width = (obj.scaleX == 0) ? 0 : width / obj.scaleX;
+            height = (obj.scaleY == 0) ? 0 : height / obj.scaleY;
+        }
+        
+		// We are already taking scale into account from the transform,
+		// so adjust here since IUIComponent mixes it with width/height
+		var pos:Point = new Point();
+		MatrixUtil.transformBounds(width, height,
+                            	   transformMatrix,
+                            	   pos);
+        return pos.x;
+        */
+    }
+
+    public static function getLayoutBoundsY(obj:IUIComponent/*,transformMatrix:Matrix*/):Number
+    {
+        /*if (transformMatrix == null)*/
+            return obj.y;
+
+        /*
+        var width:Number = obj.width;
+        var height:Number = obj.height;
+
+        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+        {
+            width = (obj.scaleX == 0) ? 0 : width / obj.scaleX;
+            height = (obj.scaleY == 0) ? 0 : height / obj.scaleY;
+        }
+        
+        // We are already taking scale into account from the transform,
+        // so adjust here since IUIComponent mixes it with width/height
+        var pos:Point = new Point();
+        MatrixUtil.transformBounds(width, height,
+                                   transformMatrix,
+                                   pos);
+        return pos.y;
+        */
+    }
+
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public static function setLayoutBoundsPosition(obj:IUIComponent,x:Number, y:Number/*, transformMatrix:Matrix*/):void
+    {
+        /*
+        if (transformMatrix)
+        {
+            //race("Setting actual position to " + x + "," + y);
+            //race("\tcurrent x/y is " + obj.x + "," + obj.y); 
+            //race("\tcurrent actual position is " + actualPosition.x + "," + actualPosition.y);
+            x = x - getLayoutBoundsX(obj,transformMatrix) + obj.x;
+            y = y - getLayoutBoundsY(obj,transformMatrix) + obj.y;
+        }
+        */
+        obj.move(x, y);
+    }
+
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public static function setLayoutBoundsSize(obj:IUIComponent,width:Number,
+                                               height:Number/*,
+                                               transformMatrix:Matrix*/):void
+    {
+        /*
+        if (!transformMatrix)
+        {*/
+            if (isNaN(width))
+                width = getPreferredUBoundsWidth(obj);
+            if (isNaN(height))
+                height = getPreferredUBoundsHeight(obj);
+    
+            /*
+            if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+            {
+                // We are already taking scale into account from the transform,
+                // so adjust here since IUIComponent mixes it with width/height
+                width *= obj.scaleX;
+                height *= obj.scaleY;
+            }
+            */
+            obj.setActualSize(width, height);
+            return;
+        /*}
+
+        var fitSize:Point = MatrixUtil.fitBounds(width, height, transformMatrix,
+                                                 obj.explicitWidth,
+                                                 obj.explicitHeight,
+                                                 getPreferredUBoundsWidth(obj),
+                                                 getPreferredUBoundsHeight(obj),
+                                                 getMinUBoundsWidth(obj),
+                                                 getMinUBoundsHeight(obj),
+                                                 getMaxUBoundsWidth(obj),
+                                                 getMaxUBoundsHeight(obj));
+
+        // If we couldn't fit at all, default to the minimum size
+        if (!fitSize)
+            fitSize = new Point(getMinUBoundsWidth(obj), getMinUBoundsHeight(obj));
+
+        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_0)
+        {
+            // We are already taking scale into account from the transform,
+            // so adjust here since IUIComponent mixes it with width/height
+            obj.setActualSize(fitSize.x * obj.scaleX, fitSize.y * obj.scaleY);
+        }
+        else
+            obj.setActualSize(fitSize.x, fitSize.y);
+        */
+    }
+}
+}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
index e042339..ef11083 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -43,16 +43,18 @@ import flash.events.IEventDispatcher;
 */
 
 import mx.controls.beads.ToolTipBead;
+import mx.display.Graphics;
 import mx.events.FlexEvent;
-import mx.events.ResizeEvent;
 import mx.events.MoveEvent;
+import mx.events.PropertyChangeEvent;
+import mx.events.ResizeEvent;
 import mx.managers.ICursorManager;
 import mx.managers.IFocusManager;
 import mx.managers.IFocusManagerContainer;
 import mx.managers.ISystemManager;
+import mx.styles.IStyleManager2;
+import mx.styles.StyleManager;
 
-import org.apache.royale.html.beads.DisableBead;
-import org.apache.royale.html.beads.DisabledAlphaBead;
 import org.apache.royale.core.CallLaterBead;
 import org.apache.royale.core.IStatesImpl;
 import org.apache.royale.core.IStatesObject;
@@ -65,40 +67,12 @@ import org.apache.royale.events.KeyboardEvent;
 import org.apache.royale.events.ValueChangeEvent;
 import org.apache.royale.geom.Point;
 import org.apache.royale.geom.Rectangle;
+import org.apache.royale.html.beads.DisableBead;
+import org.apache.royale.html.beads.DisabledAlphaBead;
 import org.apache.royale.html.supportClasses.ContainerContentArea;
 import org.apache.royale.utils.PointUtils;
 import org.apache.royale.utils.loadBeadFromValuesManager;
 
-import mx.display.Graphics;
-
-/*
-import mx.managers.IToolTipManagerClient;
-import mx.managers.SystemManager;
-import mx.managers.SystemManagerGlobals;
-import mx.managers.ToolTipManager;
-import mx.resources.IResourceManager;
-import mx.resources.ResourceManager;
-import mx.states.State;
-import mx.states.Transition;
-import mx.styles.CSSStyleDeclaration;
-import mx.styles.IAdvancedStyleClient;
-import mx.styles.ISimpleStyleClient;
-import mx.styles.IStyleClient;
-import mx.styles.StyleProtoChain;
-import mx.utils.ColorUtil;
-import mx.utils.GraphicsUtil;
-import mx.utils.MatrixUtil;
-import mx.utils.NameUtil;
-import mx.utils.StringUtil;
-import mx.utils.TransformUtil;
-import mx.validators.IValidatorListener;
-import mx.validators.ValidationResult;
-    
-use namespace mx_internal;
-*/
-import mx.styles.IStyleManager2;
-import mx.styles.StyleManager;
-
 /**
  *  Dispatched when the component has finished its construction
  *  and has all initialization properties set.
@@ -666,6 +640,43 @@ public class UIComponent extends UIBase
      */
     private var oldExplicitHeight:Number;
 
+    //----------------------------------
+    //  baselinePosition
+    //----------------------------------
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get baselinePosition():Number
+    {
+        /*
+        if (!validateBaselinePosition())
+            return NaN;
+        
+        // Unless the height is very small, the baselinePosition
+        // of a generic UIComponent is calculated as if there was
+        // a UITextField using the component's styles
+        // whose top coincides with the component's top.
+        // If the height is small, the baselinePosition is calculated
+        // as if there were text within whose ascent the component
+        // is vertically centered.
+        // At the crossover height, these two calculations
+        // produce the same result.
+        
+        var lineMetrics:TextLineMetrics = measureText("Wj");
+        
+        if (height < 2 + lineMetrics.ascent + 2)
+            return int(height + (lineMetrics.ascent - height) / 2);
+        
+        return 2 + lineMetrics.ascent;*/
+        return 0;
+    }
+
     //--------------------------------------------------------------------------
     //
     //  Variables: Styles
@@ -4454,6 +4465,220 @@ public class UIComponent extends UIBase
         }
     }
 
+    //--------------------------------------------------------------------------
+    //
+    //  ILayoutElement
+    //
+    //--------------------------------------------------------------------------
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function getPreferredBoundsWidth(postLayoutTransform:Boolean=true):Number
+    {
+        return LayoutElementUIComponentUtils.getPreferredBoundsWidth(this/*,postLayoutTransform? nonDeltaLayoutMatrix():null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function getPreferredBoundsHeight(postLayoutTransform:Boolean=true):Number
+    {
+        return LayoutElementUIComponentUtils.getPreferredBoundsHeight(this/*,postLayoutTransform? nonDeltaLayoutMatrix():null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function getMinBoundsWidth(postLayoutTransform:Boolean=true):Number
+    {
+        return LayoutElementUIComponentUtils.getMinBoundsWidth(this/*,postLayoutTransform? nonDeltaLayoutMatrix():null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function getMinBoundsHeight(postLayoutTransform:Boolean=true):Number
+    {
+        return LayoutElementUIComponentUtils.getMinBoundsHeight(this/*,postLayoutTransform? nonDeltaLayoutMatrix():null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function getMaxBoundsWidth(postLayoutTransform:Boolean=true):Number
+    {
+        return LayoutElementUIComponentUtils.getMaxBoundsWidth(this/*,postLayoutTransform? nonDeltaLayoutMatrix():null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function getMaxBoundsHeight(postLayoutTransform:Boolean=true):Number
+    {
+        return LayoutElementUIComponentUtils.getMaxBoundsHeight(this/*,postLayoutTransform? nonDeltaLayoutMatrix():null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function getBoundsXAtSize(width:Number, height:Number, postLayoutTransform:Boolean = true):Number
+    {
+        return LayoutElementUIComponentUtils.getBoundsXAtSize(this, width, height/*,
+            postLayoutTransform ? nonDeltaLayoutMatrix() : null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function getBoundsYAtSize(width:Number, height:Number, postLayoutTransform:Boolean = true):Number
+    {
+        return LayoutElementUIComponentUtils.getBoundsYAtSize(this, width, height/*,
+            postLayoutTransform ? nonDeltaLayoutMatrix() : null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function getLayoutBoundsWidth(postLayoutTransform:Boolean=true):Number
+    {
+        return LayoutElementUIComponentUtils.getLayoutBoundsWidth(this/*,postLayoutTransform? nonDeltaLayoutMatrix():null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function getLayoutBoundsHeight(postLayoutTransform:Boolean=true):Number
+    {
+        return LayoutElementUIComponentUtils.getLayoutBoundsHeight(this/*,postLayoutTransform? nonDeltaLayoutMatrix():null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function getLayoutBoundsX(postLayoutTransform:Boolean=true):Number
+    {
+        return LayoutElementUIComponentUtils.getLayoutBoundsX(this/*,postLayoutTransform? nonDeltaLayoutMatrix():null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function getLayoutBoundsY(postLayoutTransform:Boolean=true):Number
+    {
+        return LayoutElementUIComponentUtils.getLayoutBoundsY(this/*,postLayoutTransform? nonDeltaLayoutMatrix():null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function setLayoutBoundsPosition(x:Number, y:Number, postLayoutTransform:Boolean=true):void
+    {
+        LayoutElementUIComponentUtils.setLayoutBoundsPosition(this,x,y/*,postLayoutTransform? nonDeltaLayoutMatrix():null*/);
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function setLayoutBoundsSize(width:Number,
+                                        height:Number,
+                                        postLayoutTransform:Boolean = true):void
+    {
+        LayoutElementUIComponentUtils.setLayoutBoundsSize(this,width,height/*,postLayoutTransform? nonDeltaLayoutMatrix():null*/);
+    }
+
+    /** 
+     *  Helper method for dispatching a PropertyChangeEvent
+     *  when a property is updated.
+     * 
+     *  @param prop Name of the property that changed.
+     *
+     *  @param oldValue Old value of the property.
+     *
+     *  @param value New value of the property.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    protected function dispatchPropertyChangeEvent(prop:String, oldValue:*,
+                                                   value:*):void
+    {
+        if (hasEventListener("propertyChange"))
+            dispatchEvent(PropertyChangeEvent.createUpdateEvent(
+                this, prop, oldValue, value));
+    }
 
 }
 
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/GroupBase.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/GroupBase.as
index 36f332a..2e02cae 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/GroupBase.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/GroupBase.as
@@ -571,8 +571,8 @@ public class GroupBase extends UIComponent
     //  horizontalScrollPosition
     //----------------------------------
         
-    /* [Bindable]
-    [Inspectable(minValue="0.0")]      */
+    [Bindable]
+    [Inspectable(minValue="0.0")]
 
     /**
      *  @copy spark.core.IViewport#horizontalScrollPosition
@@ -582,22 +582,23 @@ public class GroupBase extends UIComponent
      *  @playerversion AIR 1.5
      *  @productversion Royale 0.9.4
      */
-    /* public function get horizontalScrollPosition():Number 
+    public function get horizontalScrollPosition():Number 
     {
         if (_layout)
         {
             return _layout.horizontalScrollPosition;
         }
+        /*
         else if (_layoutProperties && 
                 _layoutProperties.horizontalScrollPosition !== undefined)
         {
             return _layoutProperties.horizontalScrollPosition;
         }
         else
-        {
+        {*/
             return 0;
-        }
-    } */
+        /*}*/
+    }
 
     /**
      *  @private
@@ -622,8 +623,8 @@ public class GroupBase extends UIComponent
     //  verticalScrollPosition
     //----------------------------------
     
-    /* [Bindable]
-    [Inspectable(minValue="0.0")]  */
+    [Bindable]
+    [Inspectable(minValue="0.0")]
     
     /**
      *  @copy spark.core.IViewport#verticalScrollPosition
@@ -633,22 +634,23 @@ public class GroupBase extends UIComponent
      *  @playerversion AIR 1.5
      *  @productversion Royale 0.9.4
      */
-    /* public function get verticalScrollPosition():Number 
+    public function get verticalScrollPosition():Number 
     {
         if (_layout)
         {
             return _layout.verticalScrollPosition;
         }
+        /*
         else if (_layoutProperties && 
                 _layoutProperties.verticalScrollPosition !== undefined)
         {
             return _layoutProperties.verticalScrollPosition;
         }
         else
-        {
+        {*/
             return 0;
-        }
-    } */
+        /*}*/
+    }
 
     /**
      *  @private
@@ -1452,10 +1454,10 @@ public class GroupBase extends UIComponent
     //  contentWidth
     //---------------------------------- 
     
-    /* private var _contentWidth:Number = 0;
+    private var _contentWidth:Number = 0;
     
     [Bindable("propertyChange")]
-    [Inspectable(category="General")]     */
+    [Inspectable(category="General")]
 
     /**
      *  @copy spark.core.IViewport#contentWidth
@@ -1465,31 +1467,31 @@ public class GroupBase extends UIComponent
      *  @playerversion AIR 1.5
      *  @productversion Royale 0.9.4
      */
-   /*  public function get contentWidth():Number 
+    public function get contentWidth():Number 
     {
         return _contentWidth;
-    } */
+    }
     
     /**
      *  @private
      */
-    /* private function setContentWidth(value:Number):void 
+    private function setContentWidth(value:Number):void 
     {
         if (value == _contentWidth)
             return;
         var oldValue:Number = _contentWidth;
         _contentWidth = value;
         dispatchPropertyChangeEvent("contentWidth", oldValue, value);        
-    } */
+    }
 
     //----------------------------------
     //  contentHeight
     //---------------------------------- 
     
-    /* private var _contentHeight:Number = 0;
+    private var _contentHeight:Number = 0;
     
     [Bindable("propertyChange")]
-    [Inspectable(category="General")]    */ 
+    [Inspectable(category="General")]
 
     /**
      *  @copy spark.core.IViewport#contentHeight
@@ -1499,22 +1501,22 @@ public class GroupBase extends UIComponent
      *  @playerversion AIR 1.5
      *  @productversion Royale 0.9.4
      */
-    // public function get contentHeight():Number 
-    // {
-        // return _contentHeight;
-    // }
+    public function get contentHeight():Number 
+    {
+        return _contentHeight;
+    }
     
     /**
      *  @private
      */
-    /* private function setContentHeight(value:Number):void 
+    private function setContentHeight(value:Number):void 
     {            
         if (value == _contentHeight)
             return;
         var oldValue:Number = _contentHeight;
         _contentHeight = value;
         dispatchPropertyChangeEvent("contentHeight", oldValue, value);        
-    }   */  
+    }
 
     /**
      *  Sets the <code>contentWidth</code> and <code>contentHeight</code>
@@ -1532,13 +1534,13 @@ public class GroupBase extends UIComponent
      *  @playerversion AIR 1.5
      *  @productversion Royale 0.9.4
      */
-    /* public function setContentSize(width:Number, height:Number):void
+    public function setContentSize(width:Number, height:Number):void
     {
         if ((width == _contentWidth) && (height == _contentHeight))
            return;
         setContentWidth(width);
         setContentHeight(height);
-    } */
+    }
 
     //--------------------------------------------------------------------------
     //
@@ -1792,10 +1794,10 @@ public class GroupBase extends UIComponent
      *  @playerversion AIR 1.5
      *  @productversion Royale 0.9.4
      */
-    /* public function getVirtualElementAt(index:int, eltWidth:Number=NaN, eltHeight:Number=NaN):IVisualElement
+    public function getVirtualElementAt(index:int, eltWidth:Number=NaN, eltHeight:Number=NaN):IVisualElement
     {
-        return getElementAt(index);            
-    } */
+        return getElementAt(index) as IVisualElement;            
+    }
     
     /**
      *  @copy mx.core.IVisualElementContainer#getElementIndex()
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/TextBase.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/TextBase.as
index 50846f8..43297a3 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/TextBase.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/TextBase.as
@@ -38,11 +38,21 @@ import spark.core.IDisplayText;
 import spark.utils.TextUtil;
 
 import flashx.textLayout.compose.TextLineRecycler; */
-import org.apache.royale.events.Event;
 import mx.core.UIComponent;
 import mx.core.mx_internal;
 import mx.events.FlexEvent;
+
+import org.apache.royale.events.Event;
 import org.apache.royale.svg.GraphicShape;
+
+COMPILE::JS
+{
+    import window.Text;
+    import org.apache.royale.html.util.addElementToWrapper;
+    import org.apache.royale.core.WrappedHTMLElement;
+}
+import org.apache.royale.core.ITextModel;
+
 use namespace mx_internal;
 
 //--------------------------------------
@@ -500,46 +510,98 @@ public class TextBase extends UIComponent
     //  text
     //----------------------------------
 
-    /**
-     *  @private
-     */
-    mx_internal var _text:String = "";
-        
-    [Inspectable(category="General", defaultValue="")]
-    
-    /**
-     *  The text displayed by this text component.
-	 *
-     *  <p>The formatting of this text is controlled by CSS styles.
-     *  The supported styles depend on the subclass.</p>
-	 *
-	 *  @default ""
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    public function get text():String 
-    {
-        return _text;
-    }
-    
-    /**
-     *  @private
-     */
-    public function set text(value:String):void
-    {
-        if (value != _text)
-        {
-            _text = value;
+     //----------------------------------
+     //  text
+     //----------------------------------
+     
+     
+     COMPILE::JS
+     protected var textNode:window.Text;
+     
+     mx_internal var _text:String = "";
+     
+     [Bindable("textChange")]
+     /**
+      *  The text to display in the label.
+      *
+      *  @langversion 3.0
+      *  @playerversion Flash 10.2
+      *  @playerversion AIR 2.6
+      *  @productversion Royale 0.0
+      */
+     public function get text():String
+     {
+         COMPILE::SWF
+             {
+                 return ITextModel(model).text;
+             }
+             COMPILE::JS
+             {
+                 return _text;
+             }
+     }
+     
+     /**
+      *  @private
+      */
+     public function set text(value:String):void
+     {
+         COMPILE::SWF
+             {
+                 ITextModel(model).text = value;
+             }
+             COMPILE::JS
+             {
+                 if (textNode)
+                 {
+                     _text = value;
+                     textNode.nodeValue = value;
+                     this.dispatchEvent('textChange');
+                 }
+             }
+             
+             invalidateSize();
+         
+     }
+
+     /**
+      *  @private
+      */
+     COMPILE::SWF
+     override public function addedToParent():void
+     {
+         super.addedToParent();
+         model.addEventListener("textChange", repeaterListener);
+         model.addEventListener("htmlChange", repeaterListener);
+     }
+     
+     /**
+      * @royaleignorecoercion window.Text
+      */
+     COMPILE::JS
+     override protected function createElement():WrappedHTMLElement
+     {
+         addElementToWrapper(this,'span');
+         
+         textNode = document.createTextNode(_text) as window.Text;
+         element.appendChild(textNode);
+         
+         element.style.whiteSpace = "nowrap";
+         element.style.display = "inline-block";
+         
+         return element;
+     }
+     
+     COMPILE::JS
+     override public function setActualSize(w:Number, h:Number):void
+     {
+         // For HTML/JS, we only set the size if there is an explicit
+         // size set. 
+         if (!isNaN(explicitWidth)) setWidth(w);
+         if (!isNaN(explicitHeight)) setHeight(h);
+     }
+     
 
-           // invalidateTextLines();
-            invalidateSize();
-            invalidateDisplayList();
-        }
-    }
-    
     //--------------------------------------------------------------------------
     /**
      *  @private
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/core/NavigationUnit.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/core/NavigationUnit.as
new file mode 100644
index 0000000..31e6e81
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/core/NavigationUnit.as
@@ -0,0 +1,181 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.core
+{
+import org.apache.royale.events.KeyboardEvent;
+
+/**
+ *  The NavigationUnit class defines the possible values for the 
+ *  <code>getVerticalScrollPositionDelta()</code> and 
+ *  <code>getHorizontalScrollPositionDelta()</code> 
+ *  methods of the IViewport class.
+ * 
+ *  <p>All of these constants have the same values as their flash.ui.Keyboard
+ *  counterparts, except PAGE_LEFT and PAGE_RIGHT, for which no keyboard
+ *  key equivalents exist.</p>
+ * 
+ *  @see flash.ui.Keyboard
+ *  @see IViewport#getVerticalScrollPositionDelta
+ *  @see IViewport#getHorizontalScrollPositionDelta
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+public final class NavigationUnit
+{
+    /**
+     *  Navigate to the origin of the document.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const HOME:uint = KeyboardEvent.KEYCODE_HOME;
+    
+    /**
+     *  Navigate to the end of the document.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const END:uint = KeyboardEvent.KEYCODE_END;
+    
+    /**
+     *  Navigate one line or "step" upwards.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const UP:uint = KeyboardEvent.KEYCODE_UP;
+    
+    /**
+     *  Navigate one line or "step" downwards.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const DOWN:uint = KeyboardEvent.KEYCODE_DOWN;
+    
+    /**
+     *  Navigate one line or "step" to the left.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const LEFT:uint = KeyboardEvent.KEYCODE_LEFT;
+    
+    /**
+     *  Navigate one line or "step" to the right.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const RIGHT:uint = KeyboardEvent.KEYCODE_RIGHT;
+    
+    /**
+     *  Navigate one page upwards.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const PAGE_UP:uint = KeyboardEvent.KEYCODE_PAGEUP;
+    
+    /**
+     *  Navigate one page downwards.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const PAGE_DOWN:uint = KeyboardEvent.KEYCODE_PAGEDOWN;
+    
+    /**
+     *  Navigate one page to the left.
+     * 
+     *  The value of this constant, 0x2397, is the same as the Unicode
+     *  "previous page" character. 
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const PAGE_LEFT:uint = 0x2397;
+    
+    /**
+     *  Navigate one page to the right.
+     * 
+     *  The value of this constant, 0x2398, is the same as the Unicode
+     *  "next page" character. 
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const PAGE_RIGHT:uint = 0x2398;
+    
+    /**
+     *  Returns <code>true</code> if the <code>keyCode</code> maps directly 
+     *  to a NavigationUnit enum value.
+     *
+     *  @param keyCode A key code value. 
+     *
+     *  @return <code>true</code> if the <code>keyCode</code> maps directly 
+     *  to a NavigationUnit enum value.
+     * 
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static function isNavigationUnit(keyCode:uint):Boolean
+    {
+        switch (keyCode)
+        {
+            case KeyboardEvent.KEYCODE_LEFT:         return true;
+            case KeyboardEvent.KEYCODE_RIGHT:        return true;
+            case KeyboardEvent.KEYCODE_UP:           return true;
+            case KeyboardEvent.KEYCODE_DOWN:         return true;
+            case KeyboardEvent.KEYCODE_PAGEUP:      return true;
+            case KeyboardEvent.KEYCODE_PAGEDOWN:    return true;
+            case KeyboardEvent.KEYCODE_HOME:         return true;
+            case KeyboardEvent.KEYCODE_END:          return true;
+            default:                    return false;
+        }
+    }
+}
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/HorizontalAlign.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/HorizontalAlign.as
new file mode 100644
index 0000000..022d95f
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/HorizontalAlign.as
@@ -0,0 +1,94 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.layouts
+{
+
+/**
+ *  The HorizontalAlign class defines the possible values for the 
+ *  <code>horizontalAlign</code> property of the VerticalLayout class.
+ * 
+ * @see VerticalLayout#horizontalAlign
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+public final class HorizontalAlign
+{   
+    /**
+     *  Align children to the left of the container.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const LEFT:String = "left";
+
+    /**
+     *  Align children in the center of the container.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const CENTER:String = "center";
+
+    /**
+     *  Align children to the right of the container.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const RIGHT:String = "right";
+
+    /**
+     *  Justify the children with respect to the container.
+     *  This uniformly sizes all children to be the same width as the 
+     *  container.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const JUSTIFY:String = "justify";
+
+    /**
+     *  Content justify the children with respect to the container.  
+     *  This uniformly sizes all children to be the content width of the container.
+     *  The content width of the container is the size of the largest child.
+     *  If all children are smaller than the width of the container, then 
+     *  all the children will be sized to the width of the container.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const CONTENT_JUSTIFY:String = "contentJustify";
+    
+}
+
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/HorizontalLayout.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/HorizontalLayout.as
index d310fba..c6a67ce 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/HorizontalLayout.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/HorizontalLayout.as
@@ -19,12 +19,7 @@
 
 package spark.layouts
 {
-/*import flash.events.Event;
-import flash.geom.Point;
-import flash.geom.Rectangle;
-
 import mx.containers.utilityClasses.Flex;
-import mx.core.FlexVersion;
 import mx.core.ILayoutElement;
 import mx.core.IVisualElement;
 import mx.core.mx_internal;
@@ -36,9 +31,13 @@ import spark.core.NavigationUnit;
 import spark.layouts.supportClasses.DropLocation;
 import spark.layouts.supportClasses.LayoutBase;
 import spark.layouts.supportClasses.LayoutElementHelper;
-import spark.layouts.supportClasses.LinearLayoutVector; */
+import spark.layouts.supportClasses.LinearLayoutVector;
+
 import org.apache.royale.events.Event;
-//use namespace mx_internal;
+import org.apache.royale.geom.Point;
+import org.apache.royale.geom.Rectangle;
+
+use namespace mx_internal;
 
 /**
  *  The HorizontalLayout class arranges the layout elements in a horizontal sequence,
@@ -121,11 +120,11 @@ import org.apache.royale.events.Event;
  *  @langversion 3.0
  *  @playerversion Flash 10
  *  @playerversion AIR 1.5
- *  @productversion Royale 0.9.4
+ *  @productversion Flex 4
  */
-public class HorizontalLayout extends Object
-{  //extends LayoutBase
-   // include "../core/Version.as";
+public class HorizontalLayout extends LayoutBase
+{
+//    include "../core/Version.as";
 
     /**
      *  @private
@@ -133,7 +132,7 @@ public class HorizontalLayout extends Object
      *  useVirtualLayout=true.   See updateLLV(), resetCachedVirtualLayoutState(),
      *  etc.
      */
-    //private var llv:LinearLayoutVector;
+    private var llv:LinearLayoutVector;
     
     //--------------------------------------------------------------------------
     //
@@ -141,9 +140,10 @@ public class HorizontalLayout extends Object
     //
     //--------------------------------------------------------------------------
     
-   /*  private static function calculatePercentHeight(layoutElement:ILayoutElement, height:Number):Number
+    private static function calculatePercentHeight(layoutElement:ILayoutElement, height:Number):Number
     {
         var percentHeight:Number;
+        /*
         if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_6)
         {
             percentHeight = LayoutElementHelper.pinBetween(Math.round(layoutElement.percentHeight * 0.01 * height),
@@ -152,15 +152,15 @@ public class HorizontalLayout extends Object
             return percentHeight < height ? percentHeight : height;
         }
         else
-        {
+        {*/
             percentHeight = LayoutElementHelper.pinBetween(Math.min(Math.round(layoutElement.percentHeight * 0.01 * height), height),
                                                            layoutElement.getMinBoundsHeight(),
                                                            layoutElement.getMaxBoundsHeight() );
             return percentHeight;
-        }
-    } */
+        /*}*/
+    }
 
-  /*   private static function sizeLayoutElement(layoutElement:ILayoutElement, height:Number, 
+    private static function sizeLayoutElement(layoutElement:ILayoutElement, height:Number, 
                                               verticalAlign:String, restrictedHeight:Number, 
                                               width:Number, variableColumnWidth:Boolean, 
                                               columnWidth:Number):void
@@ -185,7 +185,7 @@ public class HorizontalLayout extends Object
             layoutElement.setLayoutBoundsSize(width, newHeight);
         else
             layoutElement.setLayoutBoundsSize(columnWidth, newHeight);
-    } */
+    }
         
     //--------------------------------------------------------------------------
     //
@@ -199,14 +199,14 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */    
     public function HorizontalLayout():void
     {
         super();
 
         // Don't drag-scroll in the vertical direction
-      //  dragScrollRegionSizeVertical = 0;
+        dragScrollRegionSizeVertical = 0;
     }
     
     //--------------------------------------------------------------------------
@@ -223,7 +223,7 @@ public class HorizontalLayout extends Object
      *  @private
      *  Storage for the alignmentBaseline property.
      */
-  //  private var _alignmentBaseline:Object = "maxAscent:0";
+    private var _alignmentBaseline:Object = "maxAscent:0";
 
     /**
      *  @private
@@ -245,24 +245,24 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 2.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4.5
      */
-    /* mx_internal function get alignmentBaseline():Object
+    mx_internal function get alignmentBaseline():Object
     {
         return _alignmentBaseline;
-    } */
+    }
 
     /**
      *  @private
      */
-    /* mx_internal function set alignmentBaseline(value:Object):void
+    mx_internal function set alignmentBaseline(value:Object):void
     {
         if (_alignmentBaseline == value) 
             return;
         
         _alignmentBaseline = value;
         invalidateTargetSizeAndDisplayList();
-    } */
+    }
 
     //----------------------------------
     //  gap
@@ -283,7 +283,7 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */    
     public function get gap():int
     {
@@ -299,17 +299,17 @@ public class HorizontalLayout extends Object
             return;
     
         _gap = value;
-      //  invalidateTargetSizeAndDisplayList();
+        invalidateTargetSizeAndDisplayList();
     }
     
     //----------------------------------
     //  columnCount
     //----------------------------------
 
-    /* private var _columnCount:int = -1;
+    private var _columnCount:int = -1;
     
     [Bindable("propertyChange")]
-    [Inspectable(category="General")] */
+    [Inspectable(category="General")]
 
     /**
      *  Returns the current number of elements in view.
@@ -319,12 +319,12 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
-   /*  public function get columnCount():int
+    public function get columnCount():int
     {
         return _columnCount;
-    } */
+    }
 
     /**
      *  @private
@@ -332,14 +332,14 @@ public class HorizontalLayout extends Object
      *  Sets the <code>columnCount</code> property and dispatches
      *  a PropertyChangeEvent.
      */
-   /*  private function setColumnCount(value:int):void
+    private function setColumnCount(value:int):void
     {
         if (_columnCount == value)
             return;
         var oldValue:int = _columnCount;
         _columnCount = value;
         dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "columnCount", oldValue, value));
-    } */
+    }
 	
 	//----------------------------------
 	//  padding
@@ -358,7 +358,7 @@ public class HorizontalLayout extends Object
 	 *  @langversion 3.0
 	 *  @playerversion Flash 10
 	 *  @playerversion AIR 1.5
-	 *  @productversion Royale 0.9.4
+	 *  @productversion Flex 4
 	 */
 	public function get padding():Number
 	{
@@ -380,7 +380,7 @@ public class HorizontalLayout extends Object
 		paddingRight = _padding;
 		paddingTop = _padding;
 		
-		//invalidateTargetSizeAndDisplayList();
+		invalidateTargetSizeAndDisplayList();
 	}    
         
     //----------------------------------
@@ -400,7 +400,7 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
     public function get paddingLeft():Number
     {
@@ -416,7 +416,7 @@ public class HorizontalLayout extends Object
             return;
                                
         _paddingLeft = value;
-      //  invalidateTargetSizeAndDisplayList();
+        invalidateTargetSizeAndDisplayList();
     }    
     
     //----------------------------------
@@ -436,7 +436,7 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
     public function get paddingRight():Number
     {
@@ -452,7 +452,7 @@ public class HorizontalLayout extends Object
             return;
                                
         _paddingRight = value;
-       // invalidateTargetSizeAndDisplayList();
+        invalidateTargetSizeAndDisplayList();
     }    
     
     //----------------------------------
@@ -472,7 +472,7 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
     public function get paddingTop():Number
     {
@@ -488,7 +488,7 @@ public class HorizontalLayout extends Object
             return;
                                
         _paddingTop = value;
-      //  invalidateTargetSizeAndDisplayList();
+        invalidateTargetSizeAndDisplayList();
     }    
     
     //----------------------------------
@@ -508,7 +508,7 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
     public function get paddingBottom():Number
     {
@@ -524,16 +524,16 @@ public class HorizontalLayout extends Object
             return;
                                
         _paddingBottom = value;
-      //  invalidateTargetSizeAndDisplayList();
+        invalidateTargetSizeAndDisplayList();
     }    
 
     //----------------------------------
     //  requestedMaxColumnCount
     //----------------------------------
     
-   /*  private var _requestedMaxColumnCount:int = -1;
+    private var _requestedMaxColumnCount:int = -1;
     
-    [Inspectable(category="General", minValue="-1")] */
+    [Inspectable(category="General", minValue="-1")]
     
     /**
      *  The measured width of this layout is large enough to display 
@@ -552,17 +552,17 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 2.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4.5
      */
-   /*  public function get requestedMaxColumnCount():int
+    public function get requestedMaxColumnCount():int
     {
         return _requestedMaxColumnCount;
-    } */
+    }
     
     /**
      *  @private
      */
-    /* public function set requestedMaxColumnCount(value:int):void
+    public function set requestedMaxColumnCount(value:int):void
     {
         if (_requestedMaxColumnCount == value)
             return;
@@ -571,15 +571,15 @@ public class HorizontalLayout extends Object
         
         if (target)
             target.invalidateSize();
-    }   */ 
+    }   
     
     //----------------------------------
     //  requestedMinColumnCount
     //----------------------------------
     
-    /* private var _requestedMinColumnCount:int = -1;
+    private var _requestedMinColumnCount:int = -1;
     
-    [Inspectable(category="General", minValue="-1")] */
+    [Inspectable(category="General", minValue="-1")]
     
     /**
      *  The measured width of this layout is large enough to display 
@@ -598,17 +598,17 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 2.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4.5
      */
-    /* public function get requestedMinColumnCount():int
+    public function get requestedMinColumnCount():int
     {
         return _requestedMinColumnCount;
-    } */
+    }
 
     /**
      *  @private
      */
-    /* public function set requestedMinColumnCount(value:int):void
+    public function set requestedMinColumnCount(value:int):void
     {
         if (_requestedMinColumnCount == value)
             return;
@@ -617,15 +617,15 @@ public class HorizontalLayout extends Object
 
         if (target)
             target.invalidateSize();
-    } */   
+    }   
 
     //----------------------------------
     //  requestedColumnCount
     //----------------------------------
 
-   /*  private var _requestedColumnCount:int = -1;
+    private var _requestedColumnCount:int = -1;
     
-    [Inspectable(category="General", minValue="-1")] */
+    [Inspectable(category="General", minValue="-1")]
 
     /**
      *  The measured size of this layout is wide enough to display 
@@ -643,17 +643,17 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
-    /* public function get requestedColumnCount():int
+    public function get requestedColumnCount():int
     {
         return _requestedColumnCount;
-    } */
+    }
 
     /**
      *  @private
      */
-    /* public function set requestedColumnCount(value:int):void
+    public function set requestedColumnCount(value:int):void
     {
         if (_requestedColumnCount == value)
             return;
@@ -662,15 +662,15 @@ public class HorizontalLayout extends Object
         
         if (target)
             target.invalidateSize();
-    } */    
+    }    
     
     //----------------------------------
     //  columnWidth
     //----------------------------------
     
-   /*  private var _columnWidth:Number;
+    private var _columnWidth:Number;
 
-    [Inspectable(category="General", minValue="0.0")] */
+    [Inspectable(category="General", minValue="0.0")]
 
     /**
      *  If the <code>variableColumnWidth</code> property is <code>false</code>, 
@@ -685,9 +685,9 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
-    /* public function get columnWidth():Number
+    public function get columnWidth():Number
     {
         if (!isNaN(_columnWidth))
             return _columnWidth;
@@ -696,19 +696,19 @@ public class HorizontalLayout extends Object
             var elt:ILayoutElement = typicalLayoutElement
             return (elt) ? elt.getPreferredBoundsWidth() : 0;
         }
-    } */
+    }
 
     /**
      *  @private
      */
-    /* public function set columnWidth(value:Number):void
+    public function set columnWidth(value:Number):void
     {
         if (_columnWidth == value)
             return;
             
         _columnWidth = value;
         invalidateTargetSizeAndDisplayList();
-    } */
+    }
 
     //----------------------------------
     //  variableColumnWidth
@@ -717,9 +717,9 @@ public class HorizontalLayout extends Object
     /**
      *  @private
      */
-    /* private var _variableColumnWidth:Boolean = true;
+    private var _variableColumnWidth:Boolean = true;
 
-    [Inspectable(category="General", enumeration="true,false")] */
+    [Inspectable(category="General", enumeration="true,false")]
 
     /**
      *  If <code>true</code>, specifies that layout elements are to be allocated their
@@ -735,23 +735,23 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
-    /* public function get variableColumnWidth():Boolean
+    public function get variableColumnWidth():Boolean
     {
         return _variableColumnWidth;
-    } */
+    }
 
     /**
      *  @private
      */
-    /* public function set variableColumnWidth(value:Boolean):void
+    public function set variableColumnWidth(value:Boolean):void
     {
         if (value == _variableColumnWidth) return;
         
         _variableColumnWidth = value;
         invalidateTargetSizeAndDisplayList();
-    } */
+    }
     
     //----------------------------------
     //  firstIndexInView
@@ -760,10 +760,10 @@ public class HorizontalLayout extends Object
     /**
      *  @private
      */
-    /* private var _firstIndexInView:int = -1;
+    private var _firstIndexInView:int = -1;
 
     [Inspectable(category="General")]
-    [Bindable("indexInViewChanged")]  */   
+    [Bindable("indexInViewChanged")]    
 
     /**
      *  The index of the first column that is part of the layout and within
@@ -777,12 +777,12 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
-    /* public function get firstIndexInView():int
+    public function get firstIndexInView():int
     {
         return _firstIndexInView;
-    } */
+    }
     
     
     //----------------------------------
@@ -792,10 +792,10 @@ public class HorizontalLayout extends Object
     /**
      *  @private
      */
-    /* private var _lastIndexInView:int = -1;
+    private var _lastIndexInView:int = -1;
     
     [Inspectable(category="General")]
-    [Bindable("indexInViewChanged")]   */  
+    [Bindable("indexInViewChanged")]    
 
     /**
      *  The index of the last column that is part of the layout and within
@@ -809,12 +809,12 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
-    /* public function get lastIndexInView():int
+    public function get lastIndexInView():int
     {
         return _lastIndexInView;
-    } */
+    }
     
     //----------------------------------
     //  horizontalAlign
@@ -823,7 +823,7 @@ public class HorizontalLayout extends Object
     /**
      *  @private
      */
-    private var _horizontalAlign:String = "left";//HorizontalAlign.LEFT;
+    private var _horizontalAlign:String = HorizontalAlign.LEFT;
     
     [Inspectable(category="General", enumeration="left,right,center", defaultValue="left")]
     
@@ -842,7 +842,7 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
     public function get horizontalAlign():String
     {
@@ -858,10 +858,10 @@ public class HorizontalLayout extends Object
             return;
         
         _horizontalAlign = value;
-       /*  
+        
         var layoutTarget:GroupBase = target;
         if (layoutTarget)
-            layoutTarget.invalidateDisplayList(); */
+            layoutTarget.invalidateDisplayList();
     }
     
     //----------------------------------
@@ -871,7 +871,7 @@ public class HorizontalLayout extends Object
     /**
      *  @private
      */
-    private var _verticalAlign:String = "top";// VerticalAlign.TOP;
+    private var _verticalAlign:String = VerticalAlign.TOP;
 
     [Inspectable(category="General", enumeration="top,bottom,middle,justify,contentJustify,baseline", defaultValue="top")]
 
@@ -900,7 +900,7 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
     public function get verticalAlign():String
     {
@@ -919,7 +919,7 @@ public class HorizontalLayout extends Object
         _verticalAlign = value;
 
         // "baseline" affects the measured size
-        /* if (oldValue == VerticalAlign.BASELINE ||
+        if (oldValue == VerticalAlign.BASELINE ||
             value    == VerticalAlign.BASELINE)
         {
             invalidateTargetSizeAndDisplayList();
@@ -929,7 +929,7 @@ public class HorizontalLayout extends Object
             var layoutTarget:GroupBase = target;
             if (layoutTarget)
                 layoutTarget.invalidateDisplayList();
-        } */
+        }
     }
 
     /**
@@ -945,7 +945,7 @@ public class HorizontalLayout extends Object
      *  @see firstIndexInView
      *  @see lastIndexInview
      */
-    /* private function setIndexInView(firstIndex:int, lastIndex:int):void
+    private function setIndexInView(firstIndex:int, lastIndex:int):void
     {
         if ((_firstIndexInView == firstIndex) && (_lastIndexInView == lastIndex))
             return;
@@ -953,7 +953,7 @@ public class HorizontalLayout extends Object
         _firstIndexInView = firstIndex;
         _lastIndexInView = lastIndex;
         dispatchEvent(new Event("indexInViewChanged"));
-    } */
+    }
     
     //--------------------------------------------------------------------------
     //
@@ -964,7 +964,7 @@ public class HorizontalLayout extends Object
     /**
      *  @private
      */
-    /* override public function set clipAndEnableScrolling(value:Boolean):void
+    override public function set clipAndEnableScrolling(value:Boolean):void
     {
         super.clipAndEnableScrolling = value;
         var hAlign:String = horizontalAlign;
@@ -974,12 +974,12 @@ public class HorizontalLayout extends Object
             if (g)
                 g.invalidateDisplayList();
         }
-    } */
+    }
 
     /**
      * @private
      */
-    /* override public function clearVirtualLayoutCache():void
+    override public function clearVirtualLayoutCache():void
     {
         llv = null;
 
@@ -989,12 +989,12 @@ public class HorizontalLayout extends Object
         
         target.invalidateSize();
         target.invalidateDisplayList();
-    } */     
+    }     
 
     /**
      *  @private
      */
-    /* override public function getElementBounds(index:int):Rectangle
+    override public function getElementBounds(index:int):Rectangle
     {
         if (!useVirtualLayout)
             return super.getElementBounds(index);
@@ -1007,7 +1007,7 @@ public class HorizontalLayout extends Object
         updateLLV(g);
 		
         return llv.getBounds(index);
-    }  */   
+    }    
     
     /**
      *  Returns 1.0 if the specified index is completely in view, 0.0 if
@@ -1032,9 +1032,9 @@ public class HorizontalLayout extends Object
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
+     *  @productversion Flex 4
      */
-    /* public function fractionOfElementInView(index:int):Number
+    public function fractionOfElementInView(index:int):Number
     {
         var g:GroupBase = target;
         if (!g)
@@ -1069,7 +1069,7 @@ public class HorizontalLayout extends Object
         }
         else 
         {
-            var elt:ILayoutElement = g.getElementAt(index);
+            var elt:ILayoutElement = g.getElementAt(index) as ILayoutElement;
             if (!elt || !elt.includeInLayout)
                 return 0.0;
             eltX = elt.getLayoutBoundsX();
@@ -1089,7 +1089,7 @@ public class HorizontalLayout extends Object
         if ((ix0 >= x0) && (ix1 <= x1))
             return 1.0;
         return (Math.min(x1, ix1) - Math.max(x0, ix0)) / (ix1 - ix0);
-    } */
+    }
 
     /**
      *  @private
@@ -1104,10 +1104,10 @@ public class HorizontalLayout extends Object
      * 
      *  Returns the index of the element that contains x, or -1.
      */
-    /* private static function findIndexAt(x:Number, gap:int, g:GroupBase, i0:int, i1:int):int
+    private static function findIndexAt(x:Number, gap:int, g:GroupBase, i0:int, i1:int):int
     {
         var index:int = (i0 + i1) / 2;
-        var element:ILayoutElement = g.getElementAt(index);        
+        var element:ILayoutElement = g.getElementAt(index) as ILayoutElement;        
         var elementX:Number = element.getLayoutBoundsX();
         // TBD: deal with null element, includeInLayout false.
         if ((x >= elementX) && (x < elementX + element.getLayoutBoundsWidth() + gap))
@@ -1118,7 +1118,7 @@ public class HorizontalLayout extends Object
             return findIndexAt(x, gap, g, i0, Math.max(i0, index-1));
         else 
             return findIndexAt(x, gap, g, Math.min(index+1, i1), i1);
-    }  */ 
+    }  
     
     /**
      *  @private
@@ -1128,12 +1128,12 @@ public class HorizontalLayout extends Object
      * 
      *  Returns -1 if no such element can be found.
      */
-    /* private static function findLayoutElementIndex(g:GroupBase, i:int, dir:int):int
+    private static function findLayoutElementIndex(g:GroupBase, i:int, dir:int):int
     {
         var n:int = g.numElements;
         while((i >= 0) && (i < n))
         {
-           var element:ILayoutElement = g.getElementAt(i);
+           var element:ILayoutElement = g.getElementAt(i) as ILayoutElement;
            if (element && element.includeInLayout)
            {
                return i;      
@@ -1141,7 +1141,7 @@ public class HorizontalLayout extends Object
            i += dir;
         }
         return -1;
-    }  */
+    } 
     
     /**
      *  @private
@@ -1151,7 +1151,7 @@ public class HorizontalLayout extends Object
      *  
      *  @see setIndexInView
      */
-    /* override protected function scrollPositionChanged():void
+    override protected function scrollPositionChanged():void
     {
         super.scrollPositionChanged();
         
@@ -1213,7 +1213,7 @@ public class HorizontalLayout extends Object
             var index0:int = findLayoutElementIndex(g, 0, +1);
             if (index0 != -1)
             {
-                var element0:ILayoutElement = g.getElementAt(index0); 
+                var element0:ILayoutElement = g.getElementAt(index0) as ILayoutElement; 
                 var element0X:Number = element0.getLayoutBoundsX();
                 var element0Width:Number = element0.getLayoutBoundsWidth();                 
                 if ((element0X < x1) && ((element0X + element0Width) > x0))
@@ -1227,7 +1227,7 @@ public class HorizontalLayout extends Object
             var index1:int = findLayoutElementIndex(g, n, -1);
             if (index1 != -1)
             {
-                var element1:ILayoutElement = g.getElementAt(index1); 
+                var element1:ILayoutElement = g.getElementAt(index1) as ILayoutElement; 
                 var element1X:Number = element1.getLayoutBoundsX();
                 var element1Width:Number = element1.getLayoutBoundsWidth();                 
                 if ((element1X < x1) && ((element1X + element1Width) > x0))
@@ -1237,13 +1237,13 @@ public class HorizontalLayout extends Object
 
         if (useVirtualLayout)
         {
-            var firstElement:ILayoutElement = g.getElementAt(_firstIndexInView);
-            var lastElement:ILayoutElement = g.getElementAt(_lastIndexInView);
+            var firstElement:ILayoutElement = g.getElementAt(_firstIndexInView) as ILayoutElement;
+            var lastElement:ILayoutElement = g.getElementAt(_lastIndexInView) as ILayoutElement;
             var scrollRect:Rectangle = getScrollRect();
             
             /* If the scrollRect is within the bounds of the elements, we do
             not need to call invalidateDisplayList(). This considerably speeds
-            up small scrolls. */ /*
+            up small scrolls. */
             if (!firstElement || !lastElement || 
                 scrollRect.left < firstElement.getLayoutBoundsX() || 
                 scrollRect.right >= (lastElement.getLayoutBoundsX() + lastElement.getLayoutBoundsWidth()))
@@ -1253,7 +1253,7 @@ public class HorizontalLayout extends Object
         }
                 
         setIndexInView(i0, i1);
-    } */
+    }
 
     /**
      *  @private
@@ -1266,7 +1266,7 @@ public class HorizontalLayout extends Object
      * 
      *  Returns null if no such element can be found.
      */
-   /*  private function findLayoutElementBounds(g:GroupBase, i:int, dir:int, r:Rectangle):Rectangle
+    private function findLayoutElementBounds(g:GroupBase, i:int, dir:int, r:Rectangle):Rectangle
     {
         var n:int = g.numElements;
 
@@ -1299,29 +1299,29 @@ public class HorizontalLayout extends Object
            i += dir;
         }
         return null;
-    } */
+    }
 
     /**
      *  @private 
      */
-    /* override protected function getElementBoundsLeftOfScrollRect(scrollRect:Rectangle):Rectangle
+    override protected function getElementBoundsLeftOfScrollRect(scrollRect:Rectangle):Rectangle
     {
         return findLayoutElementBounds(target, firstIndexInView, -1, scrollRect);
-    }  */
+    } 
 
     /**
      *  @private 
      */
-    /* override protected function getElementBoundsRightOfScrollRect(scrollRect:Rectangle):Rectangle
+    override protected function getElementBoundsRightOfScrollRect(scrollRect:Rectangle):Rectangle
     {
         return findLayoutElementBounds(target, lastIndexInView, +1, scrollRect);
-    }  */
+    } 
 
     /**
      *  @private
      *  Fills in the result with preferred and min sizes of the element.
      */
-    /* private function getElementWidth(element:ILayoutElement, fixedColumnWidth:Number, result:SizesAndLimit):void
+    private function getElementWidth(element:ILayoutElement, fixedColumnWidth:Number, result:SizesAndLimit):void
     {
         // Calculate preferred width first, as it's being used to calculate min width
         var elementPreferredWidth:Number = isNaN(fixedColumnWidth) ? Math.ceil(element.getPreferredBoundsWidth()) :
@@ -1332,13 +1332,13 @@ public class HorizontalLayout extends Object
                                                      elementPreferredWidth;
         result.preferredSize = elementPreferredWidth;
         result.minSize = elementMinWidth;
-    } */
+    }
     
     /**
      *  @private
      *  Fills in the result with preferred and min sizes of the element.
      */
-    /* private function getElementHeight(element:ILayoutElement, justify:Boolean, result:SizesAndLimit):void
+    private function getElementHeight(element:ILayoutElement, justify:Boolean, result:SizesAndLimit):void
     {
         // Calculate preferred height first, as it's being used to calculate min height below
         var elementPreferredHeight:Number = Math.ceil(element.getPreferredBoundsHeight());
@@ -1349,7 +1349,7 @@ public class HorizontalLayout extends Object
                                                        elementPreferredHeight;
         result.preferredSize = elementPreferredHeight;
         result.minSize = elementMinHeight;
-    } */
+    }
 
     /**
      *  @private
@@ -1357,7 +1357,7 @@ public class HorizontalLayout extends Object
      *  where baselineTop is the portion of the elements above the common baseline
      *  and the baselineBottom is the portion of the elements below the common baseline.
      */
-    /* private function calculateBaselineTopBottom(calculateBottom:Boolean):Array
+    private function calculateBaselineTopBottom(calculateBottom:Boolean):Array
     {
         var baselineOffset:Number = 0;
         var baselineTop:Number = 0;
@@ -1388,14 +1388,14 @@ public class HorizontalLayout extends Object
         var count:int = target.numElements;
         for (var i:int = 0; i < count; i++)
         {
-            var element:ILayoutElement = target.getElementAt(i);
+            var element:ILayoutElement = target.getElementAt(i) as ILayoutElement;
             if (!element || !element.includeInLayout)
                 continue;
 
-            var elementBaseline:Number = element.baseline as Number;
+            var elementBaseline:Number/* = element.baseline as Number;
             if (isNaN(elementBaseline))
-                elementBaseline = 0;
-
+                elementBaseline*/ = 0;
+            
             var baselinePosition:Number = element.baselinePosition;
 
             // The portion of the current element that's above the baseline
@@ -1424,13 +1424,13 @@ public class HorizontalLayout extends Object
             baselineTop += baselineOffset;
 
         return [baselineTop, baselineBottom, baselineBottomMin];
-    } */
+    }
 
     /**
      *  @private
      *  @return columns to measure based on elements in layout and any requested/min/max rowCount settings. 
      */
-    /* private function getColumsToMeasure(numElementsInLayout:int):int
+    private function getColumsToMeasure(numElementsInLayout:int):int
     {
         var columnsToMeasure:int;
         if (requestedColumnCount != -1)
@@ -1444,7 +1444,7 @@ public class HorizontalLayout extends Object
                 columnsToMeasure = Math.max(requestedMinColumnCount, columnsToMeasure);
         }
         return columnsToMeasure;
-    } */
+    }
     
     /**
      *  @private
@@ -1458,7 +1458,7 @@ public class HorizontalLayout extends Object
      * 
      *  If requestedColumnCount is -1, we consider width/height of each element.
      */
-    /* private function measureReal(layoutTarget:GroupBase):void
+    private function measureReal(layoutTarget:GroupBase):void
     {
         var size:SizesAndLimit          = new SizesAndLimit();
         var alignToBaseline:Boolean     = verticalAlign == VerticalAlign.BASELINE;
@@ -1482,7 +1482,7 @@ public class HorizontalLayout extends Object
         var element:ILayoutElement;
         for (var i:int = 0; i < numElements; i++)
         {
-            element = layoutTarget.getElementAt(i);
+            element = layoutTarget.getElementAt(i) as ILayoutElement;
             if (!element || !element.includeInLayout)
             {
                 numElementsInLayout--;
@@ -1536,7 +1536,7 @@ public class HorizontalLayout extends Object
 
         if (alignToBaseline)
         {
-            var result:Array = calculateBaselineTopBottom(true /*calculateBottom*//*);
+            var result:Array = calculateBaselineTopBottom(true /*calculateBottom*/);
             var top:Number = result[0];
             var bottom:Number = result[1];
             var bottomMin:Number = result[2];
@@ -1560,7 +1560,7 @@ public class HorizontalLayout extends Object
         layoutTarget.measuredWidth = preferredWidth + hPadding;
         layoutTarget.measuredMinHeight = minHeight + vPadding;
         layoutTarget.measuredMinWidth  = minWidth + hPadding;
-    } */
+    }
 
     /**
      *  @private
@@ -1570,7 +1570,7 @@ public class HorizontalLayout extends Object
      *  for the possibility that the typicalLayoutElement has changed, or
      *  something that its preferred size depends on has changed.
      */
-    /* private function updateLLV(layoutTarget:GroupBase):void
+    private function updateLLV(layoutTarget:GroupBase):void
     {
         if (!llv)
         {
@@ -1599,25 +1599,25 @@ public class HorizontalLayout extends Object
 
         llv.gap = gap;
         llv.majorAxisOffset = paddingLeft;
-    } */
+    }
 
     /**
      *  @private
      */
-    /*  override public function elementAdded(index:int):void
+     override public function elementAdded(index:int):void
      {
          if ((index >= 0) && useVirtualLayout && llv)
             llv.insert(index);  // insert index parameter is uint
-     } */
+     }
 
     /**
      *  @private
      */
-     /* override public function elementRemoved(index:int):void
+     override public function elementRemoved(index:int):void
      {
         if ((index >= 0) && useVirtualLayout && llv)
             llv.remove(index);  // remove index parameter is uint
-     }  */    
+     }     
 
     /**
      *  @private
@@ -1633,7 +1633,7 @@ public class HorizontalLayout extends Object
      *  llv's defaultMajorSize, minorSize, and minMinorSize 
      *  are based on typicalLayoutElement.
      */
-    /* private function measureVirtual(layoutTarget:GroupBase):void
+    private function measureVirtual(layoutTarget:GroupBase):void
     {
         var eltCount:int = layoutTarget.numElements;
         var measuredEltCount:int = getColumsToMeasure(eltCount);
@@ -1664,6 +1664,7 @@ public class HorizontalLayout extends Object
             // Measured size according to the cached actual size:
             var measuredWidth:Number = llv.end(measuredEltCount - 1) + paddingRight;
             
+            /* AJH Later
             // For the live ItemRenderers use the preferred size
             // instead of the cached actual size:
             var dataGroupTarget:DataGroup = layoutTarget as DataGroup;
@@ -1680,6 +1681,7 @@ public class HorizontalLayout extends Object
                     }
                 }
             }
+            */
             
             layoutTarget.measuredWidth = measuredWidth;
             
@@ -1696,7 +1698,7 @@ public class HorizontalLayout extends Object
         layoutTarget.measuredMinWidth = layoutTarget.measuredWidth;
         layoutTarget.measuredMinHeight = (verticalAlign == VerticalAlign.JUSTIFY) ? 
                 llv.minMinorSize + vPadding : layoutTarget.measuredHeight;
-    } */
+    }
 
     /**
      *  @private
@@ -1736,7 +1738,7 @@ public class HorizontalLayout extends Object
      *  As before the difference is due to the fact that flexible items are only
      *  guaranteed their minHeight.
      */
-    /* override public function measure():void
+    override public function measure():void
     {
         var layoutTarget:GroupBase = target;
         if (!layoutTarget)
@@ -1753,12 +1755,12 @@ public class HorizontalLayout extends Object
         layoutTarget.measuredHeight = Math.ceil(layoutTarget.measuredHeight);    
         layoutTarget.measuredMinWidth = Math.ceil(layoutTarget.measuredMinWidth);    
         layoutTarget.measuredMinHeight = Math.ceil(layoutTarget.measuredMinHeight);    
-    } */
+    }
     
     /**
      *  @private 
      */  
-    /* override public function getNavigationDestinationIndex(currentIndex:int, navigationUnit:uint, arrowKeysWrapFocus:Boolean):int
+    override public function getNavigationDestinationIndex(currentIndex:int, navigationUnit:uint, arrowKeysWrapFocus:Boolean):int
     {
         if (!target || target.numElements < 1)
             return -1; 
@@ -1893,14 +1895,14 @@ public class HorizontalLayout extends Object
             default: return super.getNavigationDestinationIndex(currentIndex, navigationUnit, arrowKeysWrapFocus);
         }
         return Math.max(0, Math.min(maxIndex, newIndex));  
-    } */
+    }
     
     /**
      *  @private
      * 
      *  Used only for virtual layout.
      */
-    /* private function calculateElementHeight(elt:ILayoutElement, targetHeight:Number, containerHeight:Number):Number
+    private function calculateElementHeight(elt:ILayoutElement, targetHeight:Number, containerHeight:Number):Number
     {
        // If percentHeight is specified then the element's height is the percentage
        // of targetHeight clipped to min/maxHeight and to (upper limit) targetHeight.
@@ -1918,14 +1920,14 @@ public class HorizontalLayout extends Object
                return Math.max(elt.getPreferredBoundsHeight(), containerHeight);
        }
        return NaN; // not constrained
-    } */
+    }
 
     /**
      *  @private
      * 
      *  Used only for virtual layout.
      */
-    /* private function calculateElementY(elt:ILayoutElement, eltHeight:Number, containerHeight:Number):Number
+    private function calculateElementY(elt:ILayoutElement, eltHeight:Number, containerHeight:Number):Number
     {
        switch(verticalAlign)
        {
@@ -1935,7 +1937,7 @@ public class HorizontalLayout extends Object
                return containerHeight - eltHeight;
        }
        return 0;  // VerticalAlign.TOP
-    } */
+    }
 
     /**
      *  @private
@@ -1980,7 +1982,7 @@ public class HorizontalLayout extends Object
      *  for the initial layout and then, if it has changed, we loop through 
      *  the layout items again and fix up the y/height values.
      */
-    /* private function updateDisplayListVirtual():void
+    private function updateDisplayListVirtual():void
     {
         var layoutTarget:GroupBase = target; 
         var eltCount:int = layoutTarget.numElements;
@@ -2049,7 +2051,7 @@ public class HorizontalLayout extends Object
             {
                 for (index = startIndex; index <= endIndex; index++)
                 {
-                    elt = layoutTarget.getElementAt(index);
+                    elt = layoutTarget.getElementAt(index) as ILayoutElement;
                     h = calculateElementHeight(elt, targetHeight, containerHeight); // can be NaN
                     elt.setLayoutBoundsSize(elt.getLayoutBoundsWidth(), h);
                     h = elt.getLayoutBoundsHeight();
@@ -2079,7 +2081,7 @@ public class HorizontalLayout extends Object
             {
                 for (index = startIndex; index <= endIndex; index++)
                 {
-                    elt = layoutTarget.getElementAt(index);
+                    elt = layoutTarget.getElementAt(index) as ILayoutElement;
                     elt.setLayoutBoundsPosition(dx + elt.getLayoutBoundsX(), elt.getLayoutBoundsY());
                 }
                 contentWidth += dx;
@@ -2094,12 +2096,12 @@ public class HorizontalLayout extends Object
         paddedContentWidth = Math.ceil(contentWidth + paddingLeft + paddingRight);
         var paddedContentHeight:Number = Math.ceil(contentHeight + paddingTop + paddingBottom);
         layoutTarget.setContentSize(paddedContentWidth, paddedContentHeight);
-    } */
+    }
     
     /**
      *  @private 
      */
-    /* private function updateDisplayListReal():void
+    private function updateDisplayListReal():void
     {
         var layoutTarget:GroupBase = target;
         var targetWidth:Number = Math.max(0, layoutTarget.width - paddingLeft - paddingRight);
@@ -2118,7 +2120,7 @@ public class HorizontalLayout extends Object
         {
             for (var i:int = 0; i < count; i++)
             {
-                layoutElement = layoutTarget.getElementAt(i);
+                layoutElement = layoutTarget.getElementAt(i) as ILayoutElement;
                 if (!layoutElement || !layoutElement.includeInLayout)
                     continue;
                 
@@ -2145,7 +2147,7 @@ public class HorizontalLayout extends Object
         var alignToBaseline:Boolean = verticalAlign == VerticalAlign.BASELINE;
         if (alignToBaseline)
         {
-            var result:Array = calculateBaselineTopBottom(false /*calculateBottom*//*);
+            var result:Array = calculateBaselineTopBottom(false /*calculateBottom*/);
             actualBaseline = result[0];
         }
 
@@ -2181,7 +2183,7 @@ public class HorizontalLayout extends Object
 
         for (var index:int = 0; index < count; index++)
         {
-            layoutElement = layoutTarget.getElementAt(index);
+            layoutElement = layoutTarget.getElementAt(index) as ILayoutElement;
             if (!layoutElement || !layoutElement.includeInLayout)
                 continue;
 
@@ -2192,9 +2194,9 @@ public class HorizontalLayout extends Object
             var y:Number;
             if (alignToBaseline)
             {
-                var elementBaseline:Number = layoutElement.baseline as Number;
+                var elementBaseline:Number/* = layoutElement.baseline as Number;
                 if (isNaN(elementBaseline))
-                    elementBaseline = 0;
+                    elementBaseline*/ = 0;
 
                 // Note: don't round the position. Rounding will case the text line to shift by
                 // a pixel and won't look aligned with the other element's text.
@@ -2234,7 +2236,7 @@ public class HorizontalLayout extends Object
         // the content size includes the whole pixel.
         layoutTarget.setContentSize(Math.ceil(maxX + paddingRight),
                                     Math.ceil(maxY + paddingBottom));
-    } */
+    }
 
 
     /**
@@ -2251,7 +2253,7 @@ public class HorizontalLayout extends Object
      *  The return value is any extra space that's left over
      *  after growing all children to their maxWidth.
      */
-    /* private function distributeWidth(width:Number,
+    private function distributeWidth(width:Number,
                                      height:Number,
                                      restrictedHeight:Number):Number
     {
@@ -2272,7 +2274,7 @@ public class HorizontalLayout extends Object
         // width and height immediately.
         for (var index:int = 0; index < count; index++)
         {
-            layoutElement = target.getElementAt(index);
+            layoutElement = target.getElementAt(index) as ILayoutElement;
             if (!layoutElement || !layoutElement.includeInLayout)
             {
                 totalCount--;
@@ -2324,12 +2326,12 @@ public class HorizontalLayout extends Object
             }
         }
         return spaceToDistribute;
-    } */
+    }
     
     /**
      *  @private
      */
-    /* override public function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
+    override public function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
     {
         super.updateDisplayList(unscaledWidth, unscaledHeight);
         
@@ -2351,7 +2353,7 @@ public class HorizontalLayout extends Object
             updateDisplayListVirtual();
         else
             updateDisplayListReal();
-    } */
+    }
     
     /**
      *  @private 
@@ -2366,7 +2368,7 @@ public class HorizontalLayout extends Object
      *  to ensure that the elements are re-arranged with the new setting and the
      *  target's default size is recomputed.</p> 
      */
-    /* private function invalidateTargetSizeAndDisplayList():void
+    private function invalidateTargetSizeAndDisplayList():void
     {
         var g:GroupBase = target;
         if (!g)
@@ -2374,7 +2376,7 @@ public class HorizontalLayout extends Object
 
         g.invalidateSize();
         g.invalidateDisplayList();
-    } */
+    }
 
     //--------------------------------------------------------------------------
     //
@@ -2385,7 +2387,7 @@ public class HorizontalLayout extends Object
     /**
      *  @private 
      */
-    /* override protected function calculateDropIndex(x:Number, y:Number):int
+    override protected function calculateDropIndex(x:Number, y:Number):int
     {
         // Iterate over the visible elements
         var layoutTarget:GroupBase = target;
@@ -2427,12 +2429,12 @@ public class HorizontalLayout extends Object
             bestIndex = getElementBounds(0).x < x ? count : 0;
 
         return bestIndex;
-    } */
+    }
     
     /**
      *  @private
      */
-    /* override protected function calculateDropIndicatorBounds(dropLocation:DropLocation):Rectangle
+    override protected function calculateDropIndicatorBounds(dropLocation:DropLocation):Rectangle
     {
         var dropIndex:int = dropLocation.dropIndex;
         var count:int = target.numElements;
@@ -2465,12 +2467,11 @@ public class HorizontalLayout extends Object
 
         var y:Number = paddingTop;
         return new Rectangle(x, y, width, height);
-    } */
+    }
 
     /**
      *  @private
-     */
-    /* override protected function calculateDragScrollDelta(dropLocation:DropLocation,
+    override protected function calculateDragScrollDelta(dropLocation:DropLocation,
                                                          elapsedTime:Number):Point
     {
         var delta:Point = super.calculateDragScrollDelta(dropLocation, elapsedTime);
@@ -2478,14 +2479,15 @@ public class HorizontalLayout extends Object
         if (delta)
             delta.y = 0;
         return delta;
-    } */
+    }
+     */
 
     /**
      *  @private
      *  Identifies the element which has its "compare point" located closest 
      *  to the specified position.
      */
-    /* override mx_internal function getElementNearestScrollPosition(
+    override mx_internal function getElementNearestScrollPosition(
         position:Point,
         elementComparePoint:String = "center"):int
     {
@@ -2528,11 +2530,11 @@ public class HorizontalLayout extends Object
                 index++;
         }
         return index;
-    } */
+    }
 }
 }
 
-/* import mx.containers.utilityClasses.FlexChildInfo;
+import mx.containers.utilityClasses.FlexChildInfo;
 import mx.core.ILayoutElement;
 class HLayoutElementFlexChildInfo extends FlexChildInfo
 {
@@ -2543,4 +2545,4 @@ class SizesAndLimit
 {
     public var preferredSize:Number;
     public var minSize:Number;
-} */
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/TileLayout.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/TileLayout.as
index a99ed1e..c13748e 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/TileLayout.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/TileLayout.as
@@ -1,2513 +1,2513 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package spark.layouts
-{
-/* import flash.geom.Point;
-import flash.geom.Rectangle; 
-
-import mx.core.ILayoutElement;
-import mx.core.IVisualElement;
-import mx.core.mx_internal;
-import mx.events.PropertyChangeEvent;
-
-import spark.components.supportClasses.GroupBase;
-import spark.core.NavigationUnit;
-import spark.layouts.supportClasses.DropLocation;
-import spark.layouts.supportClasses.LayoutBase;
-
-use namespace mx_internal;*/
-
-/**
- *  The TileLayout class arranges layout elements in columns and rows
- *  of equally-sized cells.
- *  The TileLayout class uses a number of properties that control orientation,
- *  count, size, gap and justification of the columns and the rows
- *  as well as element alignment within the cells.
- *
- *  <p>Per-element supported constraints are 
- *  <code>percentWidth</code> and <code>percentHeight</code>.
- *  Element's minimum and maximum sizes are always be respected and
- *  where possible, an element's size is limited to less then or equal
- *  of the cell size.</p>
- *
- *  <p>When not explicitly set, the <code>columnWidth</code> property 
- *  is calculated as the maximum preferred bounds width of all elements 
- *  and the <code>columnHeight</code> property is calculated
- *  as the maximum preferred bounds height of all elements.</p>
- *
- *  <p>When not explicitly set, the <code>columnCount</code> and 
- *  <code>rowCount</code> properties are calculated from
- *  any explicit width and height settings for the layout target, 
- *  and <code>columnWidth</code> and <code>columnHeight</code>.  
- *  In case none is specified, the <code>columnCount</code> and <code>rowCount</code>
- *  values are picked so that the resulting pixel area is as square as possible.</p>
- * 
- * <p> The measured size is calculated from the <code>columnCount</code>, <code>rowCount</code>, 
- *  <code>columnWidth</code>, <code>rowHeight</code> properties and the gap sizes.</p>
- *
- *  <p>The default measured size, when no properties were explicitly set, is
- *  as square as possible area and is large enough to fit all elements.</p>
- *
- *  <p>In other cases the measured size may not be big enough to fit all elements.
- *  For example, when both <code>columnCount</code> and <code>rowCount</code> are explicitly set to values
- *  such that <code>columnCount</code> &#42; <code>rowCount</code> &lt; element count.</p>
- *
- *  <p>The minimum measured size is calculated the same way as the measured size but
- *  it's guaranteed to encompass enough rows and columns along the minor axis to fit
- *  all elements.</p>
- *
- *  @mxml 
- *  <p>The <code>&lt;s:TileLayout&gt;</code> tag inherits all of the tag 
- *  attributes of its superclass and adds the following tag attributes:</p>
- *
- *  <pre>
- *  &lt;s:TileLayout 
- *    <strong>Properties</strong>
- *    columnAlign="left"
- *    columnWidth="NaN"
- *    horizontalAlign="justify"
- *    horizontalGap="6"
- *    orientation="rows"
- *    requestedColumnCount="-1"
- *    requestedRowCount="-1"
- *    rowAlign="top"
- *    rowCount="-1"
- *    rowHeight="NaN"
- *    verticalAlign="justify"
- *    verticalGap="6"
- *    padding="0"
- *  /&gt;
- *  </pre>
- *  
- *  @langversion 3.0
- *  @playerversion Flash 10
- *  @playerversion AIR 1.5
- *  @productversion Royale 0.9.4
- */
-public class TileLayout
-{ // extends LayoutBase
- //   include "../core/Version.as";
-
-    //--------------------------------------------------------------------------
-    //
-    //  Constructor
-    //
-    //--------------------------------------------------------------------------
-
-    /**
-     *  Constructor.
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    public function TileLayout():void
-    {
-        super();
-    }
-
-    //--------------------------------------------------------------------------
-    //
-    //  Properties
-    //
-    //--------------------------------------------------------------------------
-
-    //----------------------------------
-    //  horizontalGap
-    //----------------------------------
-
-   // private var explicitHorizontalGap:Number = 6;
-    private var _horizontalGap:Number = 6;
-
-    [Bindable("propertyChange")]
-    [Inspectable(category="General")]
-
-    /**
-     *  Horizontal space between columns, in pixels.
-     *
-     *  @see #verticalGap
-     *  @see #columnAlign
-     *  @default 6
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    public function get horizontalGap():Number
-    {
-        return _horizontalGap;
-    }
-
-    /**
-     *  @private
-     */
-    public function set horizontalGap(value:Number):void
-    {
-       // explicitHorizontalGap = value;
-        if (value == _horizontalGap)
-            return;
-
-        _horizontalGap = value;
-        //invalidateTargetSizeAndDisplayList();
-    }
-
-    //----------------------------------
-    //  verticalGap
-    //----------------------------------
-
-   // private var explicitVerticalGap:Number = 6;
-    private var _verticalGap:Number = 6;
-
-    [Bindable("propertyChange")]
-    [Inspectable(category="General")]
-
-    /**
-     *  Vertical space between rows, in pixels.
-     *
-     *  @see #horizontalGap
-     *  @see #rowAlign
-     *  @default 6
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    public function get verticalGap():Number
-    {
-        return _verticalGap;
-    }
-
-    /**
-     *  @private
-     */
-    public function set verticalGap(value:Number):void
-    {
-      //  explicitVerticalGap = value;
-        if (value == _verticalGap)
-            return;
-
-        _verticalGap = value;
-      //  invalidateTargetSizeAndDisplayList();
-    }
-
-    //----------------------------------
-    //  columnCount
-    //----------------------------------
-
-    /* private var _columnCount:int = -1;
-
-    [Bindable("propertyChange")]
-    [Inspectable(category="General")] */
-
-    /**
-     *  Contain the actual column count.
-     *
-     *  @see #rowCount
-     *  @see #columnAlign
-     *  @default -1
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* public function get columnCount():int
-    {
-        return _columnCount;
-    } */
-
-    //----------------------------------
-    //  requestedColumnCount
-    //----------------------------------
-
-    /**
-     *  @private
-     *  Storage for the requestedColumnCount property.
-     */
-    /* private var _requestedColumnCount:int = -1;
-    
-    [Inspectable(category="General", minValue="-1")] */
-
-    /**
-     *  Number of columns to be displayed.
-     * 
-     *  <p>Set to -1 to allow the TileLayout to determine
-     *  the column count automatically.</p>
-     *
-     *  <p>If the <code>orientation</code> property is set to <code>TileOrientation.ROWS</code>, 
-     *  then setting this property has no effect
-     *  In this case, the <code>rowCount</code> is explicitly set, and the
-     *  container width is explicitly set. </p>
-     * 
-     *  @see #columnCount
-     *  @see #columnAlign
-     *  @default -1
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* public function get requestedColumnCount():int
-    {
-        return _requestedColumnCount;
-    } */
-
-    /**
-     *  @private
-     */
-    /* public function set requestedColumnCount(value:int):void
-    {
-        if (_requestedColumnCount == value)
-            return;
-                               
-        _requestedColumnCount = value;
-        _columnCount = value;
-        invalidateTargetSizeAndDisplayList();
-    }   */  
-
-    //----------------------------------
-    //  rowCount
-    //----------------------------------
-
-    /**
-     *  @private
-     *  Storage for the rowCount property.
-     */
-   /*  private var _rowCount:int = -1;
-
-    [Bindable("propertyChange")]
-    [Inspectable(category="General")] */
-
-    /**
-     *  The row count.
-     *
-     *  @see #requestedRowCount
-     *  @see #columnCount
-     *  @default -1
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* public function get rowCount():int
-    {
-        return _rowCount;
-    } */
-
-    //----------------------------------
-    //  requestedRowCount
-    //----------------------------------
-
-    /**
-     *  @private
-     *  Storage for the requestedRowCount property.
-     */
-    /* private var _requestedRowCount:int = -1;
-    
-    [Inspectable(category="General", minValue="-1")] */
-
-    /**
-     *  Number of rows to be displayed.
-     * 
-     *  <p>Set to -1 to remove explicit override and allow the TileLayout to determine
-     *  the row count automatically.</p>
-     *
-     *  <p>If the <code>orientation</code> property is set to 
-     *  <code>TileOrientation.COLUMNS</code>, setting this property has no effect.
-     *  in this case, <code>columnCount</code> is explicitly set, and the
-     *  container height is explicitly set.</p>
-     * 
-     *  @see #rowCount
-     *  @see #rowAlign
-     *  @default -1
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* public function get requestedRowCount():int
-    {
-        return _requestedRowCount;
-    } */
-
-    /**
-     *  @private
-     */
-    /* public function set requestedRowCount(value:int):void
-    {
-        if (_requestedRowCount == value)
-            return;
-                               
-        _requestedRowCount = value;
-        _rowCount = value;
-        invalidateTargetSizeAndDisplayList();
-    }  */   
-
-    //----------------------------------
-    //  columnWidth
-    //----------------------------------
-
-    /* private var explicitColumnWidth:Number = NaN;
-    private var _columnWidth:Number = NaN;
-
-    [Bindable("propertyChange")]
-    [Inspectable(category="General", minValue="0.0")] */
-
-    /**
-     *  Contain the actual column width, in pixels.
-     *
-     *  <p>If not explicitly set, the column width is 
-     *  determined from the width of the widest element. </p>
-     *
-     *  <p>If the <code>columnAlign</code> property is set 
-     *  to <code>"justifyUsingWidth"</code>,  the column width grows to the 
-     *  container width to justify the fully-visible columns.</p>
-     *
-     *  @see #rowHeight
-     *  @see #columnAlign
-     *  @default NaN
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* public function get columnWidth():Number
-    {
-        return _columnWidth;
-    } */
-
-    /**
-     *  @private
-     */
-    /* public function set columnWidth(value:Number):void
-    {
-        explicitColumnWidth = value;
-        if (value == _columnWidth)
-            return;
-
-        _columnWidth = value;
-        invalidateTargetSizeAndDisplayList();
-    } */
-
-    //----------------------------------
-    //  rowHeight
-    //----------------------------------
-
-    /* private var explicitRowHeight:Number = NaN;
-    private var _rowHeight:Number = NaN;
-
-    [Bindable("propertyChange")]
-    [Inspectable(category="General", minValue="0.0")] */
-
-    /**
-     *  The row height, in pixels.
-     *
-     *  <p>If not explicitly set, the row height is 
-     *  determined from the maximum of elements' height.</p>
-     *
-     *  If <code>rowAlign</code> is set to "justifyUsingHeight", the actual row height
-     *  increases to justify the fully-visible rows to the container height.
-     *
-     *  @see #columnWidth
-     *  @see #rowAlign
-     *  @default NaN
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* public function get rowHeight():Number
-    {
-        return _rowHeight;
-    }
-	*/
-    /**
-     *  @private
-     */
-    /* public function set rowHeight(value:Number):void
-    {
-        explicitRowHeight = value;
-        if (value == _rowHeight)
-            return;
-
-        _rowHeight = value;
-        invalidateTargetSizeAndDisplayList();
-    } */
-	
-	//----------------------------------
-	//  padding
-	//----------------------------------
-	
-	/* private var _padding:Number = 0;
-	
-	[Inspectable(category="General")] */
-	
-	/**
-	 *  The minimum number of pixels between the container's edges and
-	 *  the edges of the layout element.
-	 * 
-	 *  @default 0
-	 *  
-	 *  @langversion 3.0
-	 *  @playerversion Flash 10
-	 *  @playerversion AIR 1.5
-	 *  @productversion Royale 0.9.4
-	 */
-	/* public function get padding():Number
-	{
-		return _padding;
-	} */
-	
-	/**
-	 *  @private
-	 */
-	public/*  function set padding(value:Number):void
-	{
-		if (_padding == value)
-			return;
-		
-		_padding = value;
-		
-		paddingBottom = _padding;
-		paddingLeft = _padding;
-		paddingRight = _padding;
-		paddingTop = _padding;
-		
-		invalidateTargetSizeAndDisplayList();
-	}   */  
-    
-    //----------------------------------
-    //  paddingLeft
-    //----------------------------------
-    
-    /* private var _paddingLeft:Number = 0;
-    
-    [Inspectable(category="General")] */
-    
-    /**
-     *  The minimum number of pixels between the container's left edge and
-     *  the left edge of the layout element.
-     * 
-     *  @default 0
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* public function get paddingLeft():Number
-    {
-        return _paddingLeft;
-    } */
-    
-    /**
-     *  @private
-     */
-    /* public function set paddingLeft(value:Number):void
-    {
-        if (_paddingLeft == value)
-            return;
-        
-        _paddingLeft = value;
-        invalidateTargetSizeAndDisplayList();
-    } */    
-    
-    //----------------------------------
-    //  paddingRight
-    //----------------------------------
-    
-   /*  private var _paddingRight:Number = 0;
-    
-    [Inspectable(category="General")] */
-    
-    /**
-     *  The minimum number of pixels between the container's right edge and
-     *  the right edge of the layout element.
-     * 
-     *  @default 0
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* public function get paddingRight():Number
-    {
-        return _paddingRight;
-    } */
-    
-    /**
-     *  @private
-     */
-    /* public function set paddingRight(value:Number):void
-    {
-        if (_paddingRight == value)
-            return;
-        
-        _paddingRight = value;
-        invalidateTargetSizeAndDisplayList();
-    } */    
-    
-    //----------------------------------
-    //  paddingTop
-    //----------------------------------
-    
-   /*  private var _paddingTop:Number = 0;
-    
-    [Inspectable(category="General")] */
-    
-    /**
-     *  Number of pixels between the container's top edge
-     *  and the top edge of the first layout element.
-     * 
-     *  @default 0
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* public function get paddingTop():Number
-    {
-        return _paddingTop;
-    } */
-    
-    /**
-     *  @private
-     */
-    /* public function set paddingTop(value:Number):void
-    {
-        if (_paddingTop == value)
-            return;
-        
-        _paddingTop = value;
-        invalidateTargetSizeAndDisplayList();
-    } */    
-    
-    //----------------------------------
-    //  paddingBottom
-    //----------------------------------
-    
-   /*  private var _paddingBottom:Number = 0;
-    
-    [Inspectable(category="General")] */
-    
-    /**
-     *  Number of pixels between the container's bottom edge
-     *  and the bottom edge of the last layout element.
-     * 
-     *  @default 0
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* public function get paddingBottom():Number
-    {
-        return _paddingBottom;
-    } */
-    
-    /**
-     *  @private
-     */
-    /* public function set paddingBottom(value:Number):void
-    {
-        if (_paddingBottom == value)
-            return;
-        
-        _paddingBottom = value;
-        invalidateTargetSizeAndDisplayList();
-    }
-     */
-    //----------------------------------
-    //  horizontalAlign
-    //----------------------------------
-
-    private var _horizontalAlign:String = "justify";// HorizontalAlign.JUSTIFY;
-
-    [Inspectable(category="General", enumeration="left,right,center,justify", defaultValue="justify")]
-
-    /**
-     *  Specifies how to align the elements within the cells in the horizontal direction.
-     *  Supported values are
-     *  <code>HorizontalAlign.LEFT</code>,
-     *  <code>HorizontalAlign.CENTER</code>,
-     *  <code>HorizontalAlign.RIGHT</code>,
-     *  <code>HorizontalAlign.JUSTIFY</code>.
-     *
-     *  <p>When set to <code>HorizontalAlign.JUSTIFY</code> the width of each
-     *  element is set to the <code>columnWidth</code>.</p>
-     *
-     *  @default <code>HorizontalAlign.JUSTIFY</code>
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    public function get horizontalAlign():String
-    {
-        return _horizontalAlign;
-    }
-
-    /**
-     *  @private
-     */
-    public function set horizontalAlign(value:String):void
-    {
-        if (_horizontalAlign == value)
-            return;
-
-        _horizontalAlign = value;
-      //  invalidateTargetSizeAndDisplayList();
-    }
-
-    //----------------------------------
-    //  verticalAlign
-    //----------------------------------
-
-    private var _verticalAlign:String = "justify"; //VerticalAlign.JUSTIFY;
-
-    [Inspectable(category="General", enumeration="top,bottom,middle,justify", defaultValue="justify")]
-
-    /**
-     *  Specifies how to align the elements within the cells in the vertical direction.
-     *  Supported values are
-     *  <code>VerticalAlign.TOP</code>,
-     *  <code>VerticalAlign.MIDDLE</code>,
-     *  <code>VerticalAlign.BOTTOM</code>,
-     *  <code>VerticalAlign.JUSTIFY</code>.
-     *
-     *  <p>When set to <code>VerticalAlign.JUSTIFY</code>, the height of each
-     *  element is set to <code>rowHeight</code>.</p>
-     *
-     *  @default <code>VerticalAlign.JUSTIFY</code>
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    public function get verticalAlign():String
-    {
-        return _verticalAlign;
-    }
-
-    /**
-     *  @private
-     */
-    public function set verticalAlign(value:String):void
-    {
-        if (_verticalAlign == value)
-            return;
-
-        _verticalAlign = value;
-       // invalidateTargetSizeAndDisplayList();
-    }
-
-    //----------------------------------
-    //  columnAlign
-    //----------------------------------
-
-   /*  private var _columnAlign:String = ColumnAlign.LEFT;
-
-    [Inspectable(category="General", enumeration="left,justifyUsingGap,justifyUsingWidth", defaultValue="left")] */
-
-    /**
-     *  Specifies how to justify the fully visible columns to the container width.
-     *  ActionScript values can be <code>ColumnAlign.LEFT</code>, <code>ColumnAlign.JUSTIFY_USING_GAP</code>
-     *  and <code>ColumnAlign.JUSTIFY_USING_WIDTH</code>.
-     *  MXML values can be <code>"left"</code>, <code>"justifyUsingGap"</code> and <code>"justifyUsingWidth"</code>.
-     *
-     *  <p>When set to <code>ColumnAlign.LEFT</code> it turns column justification off.
-     *  There may be partially visible columns or whitespace between the last column and
-     *  the right edge of the container.  This is the default value.</p>
-     *
-     *  <p>When set to <code>ColumnAlign.JUSTIFY_USING_GAP</code> the <code>horizontalGap</code>
-     *  actual value increases so that
-     *  the last fully visible column right edge aligns with the container's right edge.
-     *  In case there is only a single fully visible column, the <code>horizontalGap</code> actual value
-     *  increases so that it pushes any partially visible column beyond the right edge
-     *  of the container.  
-     *  Note that explicitly setting the <code>horizontalGap</code> property does not turn off
-     *  justification. It only determines the initial gap value. 
-     *  Justification may increases it.</p>
-     *
-     *  <p>When set to <code>ColumnAlign.JUSTIFY_USING_WIDTH</code> the <code>columnWidth</code>
-     *  actual value increases so that
-     *  the last fully visible column right edge aligns with the container's right edge.  
-     *  Note that explicitly setting the <code>columnWidth</code> property does not turn off justification.
-     *  It only determines the initial column width value. 
-     *  Justification may increases it.</p>
-     *
-     *  @see #horizontalGap
-     *  @see #columnWidth
-     *  @see #rowAlign
-     *  @default ColumnAlign.LEFT
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* public function get columnAlign():String
-    {
-        return _columnAlign;
-    } */
-
-    /**
-     *  @private
-     */
-    /* public function set columnAlign(value:String):void
-    {
-        if (_columnAlign == value)
-            return;
-
-        _columnAlign = value;
-        invalidateTargetSizeAndDisplayList();
-    } */
-
-    //----------------------------------
-    //  rowAlign
-    //----------------------------------
-
-   /*  private var _rowAlign:String = RowAlign.TOP;
-
-    [Inspectable(category="General", enumeration="top,justifyUsingGap,justifyUsingHeight", defaultValue="top")]
-	*/
-    /**
-     *  Specifies how to justify the fully visible rows to the container height.
-     *  ActionScript values can be <code>RowAlign.TOP</code>, <code>RowAlign.JUSTIFY_USING_GAP</code>
-     *  and <code>RowAlign.JUSTIFY_USING_HEIGHT</code>.
-     *  MXML values can be <code>"top"</code>, <code>"justifyUsingGap"</code> and <code>"justifyUsingHeight"</code>.
-     *
-     *  <p>When set to <code>RowAlign.TOP</code> it turns column justification off. 
-     *  There might be partially visible rows or whitespace between the last row and
-     *  the bottom edge of the container.  This is the default value.</p>
-     *
-     *  <p>When set to <code>RowAlign.JUSTIFY_USING_GAP</code> the <code>verticalGap</code>
-     *  actual value increases so that
-     *  the last fully visible row bottom edge aligns with the container's bottom edge.
-     *  In case there is only a single fully visible row, the value of <code>verticalGap</code> 
-     *  increases so that it pushes any partially visible row beyond the bottom edge
-     *  of the container.  Note that explicitly setting the <code>verticalGap</code> does not turn off
-     *  justification, but just determines the initial gap value.
-     *  Justification can then increases it.</p>
-     *
-     *  <p>When set to <code>RowAlign.JUSTIFY_USING_HEIGHT</code> the <code>rowHeight</code>
-     *  actual value increases so that
-     *  the last fully visible row bottom edge aligns with the container's bottom edge.  Note that
-     *  explicitly setting the <code>rowHeight</code> does not turn off justification, but 
-     *  determines the initial row height value.
-     *  Justification can then increase it.</p>
-     *
-     *  @see #verticalGap
-     *  @see #rowHeight
-     *  @see #columnAlign
-     *  @default RowAlign.TOP
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-   /*  public function get rowAlign():String
-    {
-        return _rowAlign;
-    } */
-
-    /**
-     *  @private
-     */
-    /* public function set rowAlign(value:String):void
-    {
-        if (_rowAlign == value)
-            return;
-
-        _rowAlign = value;
-        invalidateTargetSizeAndDisplayList();
-    } */
-
-    //----------------------------------
-    //  orientation
-    //----------------------------------
-
-   /*private var _orientation:String = TileOrientation.ROWS;
-
-    [Inspectable(category="General", enumeration="rows,columns", defaultValue="rows")]
-	*/
-    /**
-     *  Specifies whether elements are arranged row by row or
-     *  column by column.
-     *  ActionScript values can be <code>TileOrientation.ROWS</code> and 
-     *  <code>TileOrientation.COLUMNS</code>.
-     *  MXML values can be <code>"rows"</code> and <code>"columns"</code>.
-     *
-     *  @default TileOrientation.ROWS
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* public function get orientation():String
-    {
-        return _orientation;
-    } */
-
-    /**
-     *  @private
-     */
-    /* public function set orientation(value:String):void
-    {
-        if (_orientation == value)
-            return;
-
-        _orientation = value;
-        _tileWidthCached = _tileHeightCached = NaN;
-        invalidateTargetSizeAndDisplayList();
-    } */
-    
-    //----------------------------------
-    //  useVirtualLayout
-    //----------------------------------
-    
-    /**
-     *  @private
-     */
-    /* override public function set useVirtualLayout(value:Boolean):void
-    {
-        if (useVirtualLayout == value)
-            return;
-            
-        super.useVirtualLayout = value;
-        
-        // Reset the state that virtual depends on.  If the layout has already
-        // run with useVirtualLayout=false, the visibleStartEndIndex variables
-        // will have been set to 0, dataProvider.length.
-        if (value)
-        {
-            visibleStartIndex = -1;  
-            visibleEndIndex = -1;    
-            visibleStartX = 0;
-            visibleStartY = 0;
-        }
-    }   */   
-    
-    //--------------------------------------------------------------------------
-    //
-    //  Variables
-    //
-    //--------------------------------------------------------------------------
-
-    /**
-     * @private
-     */
-    /* override public function clearVirtualLayoutCache():void
-    {
-        _tileWidthCached = _tileHeightCached = NaN;
-    } */
-    
-    /**
-     *  @private
-     *  storage for old property values, in order to dispatch change events.
-     */
-    /* private var oldColumnWidth:Number = NaN;
-    private var oldRowHeight:Number = NaN;
-    private var oldColumnCount:int = -1;
-    private var oldRowCount:int = -1;
-    private var oldHorizontalGap:Number = NaN;
-    private var oldVerticalGap:Number = NaN;
-	*/
-    // Cache storage to avoid repeating work from measure() in updateDisplayList().
-    // These are set the first time the value is calculated and are reset at the end
-    // of updateDisplayList().
-    /* private var _tileWidthCached:Number = NaN;
-    private var _tileHeightCached:Number = NaN;
-    private var _numElementsCached:int = -1; */
-    
-    /**
-     *  @private
-     *  The following variables are used by updateDisplayList() and set by
-     *  calculateDisplayParameters().   If virtualLayout=true they're based 
-     *  on the current scrollRect.
-     */
-    /* private var visibleStartIndex:int = -1;   // dataProvider/layout element index  
-    private var visibleEndIndex:int = -1;     // ...
-    private var visibleStartX:Number = 0;     // first tile/cell origin
-    private var visibleStartY:Number = 0;     // ... */
-   
-    //--------------------------------------------------------------------------
-    //
-    //  Class methods
-    //
-    //--------------------------------------------------------------------------
-
-    /**
-     *  Dispatches events if Actual values have changed since the last call.
-     *  Checks columnWidth, rowHeight, columnCount, rowCount, horizontalGap, verticalGap.
-     *  This method is called from within updateDisplayList()
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* private function dispatchEventsForActualValueChanges():void
-    {
-        if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
-        {
-            if (oldColumnWidth != _columnWidth)
-                dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "columnWidth", oldColumnWidth, _columnWidth));
-            if (oldRowHeight != _rowHeight)
-                dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "rowHeight", oldRowHeight, _rowHeight));
-            if (oldColumnCount != _columnCount)
-                dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "columnCount", oldColumnCount, _columnCount));
-            if (oldRowCount != _rowCount)
-                dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "rowCount", oldRowCount, _rowCount));
-            if (oldHorizontalGap != _horizontalGap)
-                dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "horizontalGap", oldHorizontalGap, _horizontalGap));
-            if (oldVerticalGap != _verticalGap)
-                dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "verticalGap", oldVerticalGap, _verticalGap));
-        }
-
-        oldColumnWidth   = _columnWidth;
-        oldRowHeight     = _rowHeight;
-        oldColumnCount   = _columnCount;
-        oldRowCount      = _rowCount;
-        oldHorizontalGap = _horizontalGap;
-        oldVerticalGap   = _verticalGap;
-    } */
-
-    /**
-     *  This method is called from measure() and updateDisplayList() to calculate the
-     *  actual values for columnWidth, rowHeight, columnCount, rowCount, horizontalGap and verticalGap.
-     *  The width and height should include padding because the padding is accounted for in
-     *  the calculations.
-     *
-     *  @param width - the width during measure() is the layout target explicitWidth or NaN
-     *  and during updateDisplayList() is the unscaledWidth.
-     *  @param height - the height during measure() is the layout target explicitHeight or NaN
-     *  and during updateDisplayList() is the unscaledHeight.
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* private function updateActualValues(width:Number, height:Number):void
-    {
-        var widthMinusPadding:Number = width - paddingLeft - paddingRight;
-        var heightMinusPadding:Number = height - paddingTop - paddingBottom;
-        
-        // First, figure the tile size
-        calculateTileSize();
-
-        // Second, figure out number of rows/columns
-        var elementCount:int = calculateElementCount();
-        calculateColumnAndRowCount(widthMinusPadding, heightMinusPadding, elementCount);
-
-        // Third, adjust the gaps and column and row sizes based on justification settings
-        _horizontalGap = explicitHorizontalGap;
-        _verticalGap = explicitVerticalGap;
-
-        // Justify
-		if (!isNaN(width))
-		{
-            switch (columnAlign)
-            {
-                case ColumnAlign.JUSTIFY_USING_GAP:
-                    _horizontalGap = justifyByGapSize(widthMinusPadding, _columnWidth, _horizontalGap, _columnCount);
-                    break;
-                case ColumnAlign.JUSTIFY_USING_WIDTH:
-                    _columnWidth = justifyByElementSize(widthMinusPadding, _columnWidth, _horizontalGap, _columnCount);
-                    break;
-	        }
-		}
-
-		if (!isNaN(height))
-		{
-            switch (rowAlign)
-            {
-                case RowAlign.JUSTIFY_USING_GAP:
-                    _verticalGap = justifyByGapSize(heightMinusPadding, _rowHeight, _verticalGap, _rowCount);
-                    break;
-                case RowAlign.JUSTIFY_USING_HEIGHT:
-                    _rowHeight = justifyByElementSize(heightMinusPadding, _rowHeight, _verticalGap, _rowCount);
-                    break;
-	        }
-		}
-
-        // Last, if we have explicit overrides for both rowCount and columnCount, then
-        // make sure that column/row count along the minor axis reflects the actual count.
-        if (-1 != _requestedColumnCount && -1 != _requestedRowCount)
-        {
-            if (orientation == TileOrientation.ROWS)
-                _rowCount = Math.max(1, Math.ceil(elementCount / Math.max(1, _requestedColumnCount)));
-            else
-                _columnCount = Math.max(1, Math.ceil(elementCount / Math.max(1, _requestedRowCount)));
-        }
-    } */
-    
-    /**
-     *  @private
-     *  Returns true, if the dimensions (colCount1, rowCount1) are more square than (colCount2, rowCount2).
-     *  Squareness is the difference between width and height of a tile layout
-     *  with the specified number of columns and rows.
-     */
-    /* private function closerToSquare(colCount1:int, rowCount1:int, colCount2:int, rowCount2:int):Boolean
-    {
-        var difference1:Number = Math.abs(colCount1 * (_columnWidth + _horizontalGap) - _horizontalGap - 
-                                          rowCount1 * (_rowHeight   +   _verticalGap) + _verticalGap);
-        var difference2:Number = Math.abs(colCount2 * (_columnWidth + _horizontalGap) - _horizontalGap - 
-                                          rowCount2 * (_rowHeight   +   _verticalGap) + _verticalGap);
-        
-        return difference1 < difference2 || (difference1 == difference2 && rowCount1 <= rowCount2);
-    } */
-
-    /**
-     *  @private
-     *  Calculates _columnCount and _rowCount based on width, height,
-     *  orientation, _requestedColumnCount, _requestedRowCount, _columnWidth, _rowHeight.
-     *  _columnWidth and _rowHeight must be valid before calling.
-     * 
-     *  The width and height should not include padding.
-     */
-    /* private function calculateColumnAndRowCount(width:Number, height:Number, elementCount:int):void
-    {
-        _columnCount = _rowCount = -1;
-
-        if (-1 != _requestedColumnCount || -1 != _requestedRowCount)
-        {
-            if (-1 != _requestedRowCount)
-                _rowCount = Math.max(1, _requestedRowCount);
-
-            if (-1 != _requestedColumnCount)
-                _columnCount = Math.max(1, _requestedColumnCount);
-        }
-        // Figure out number of columns or rows based on the explicit size along one of the axes
-        else if (!isNaN(width) && (orientation == TileOrientation.ROWS || isNaN(height)))
-        {
-            if (_columnWidth + explicitHorizontalGap > 0)
-                _columnCount = Math.max(1, Math.floor((width + explicitHorizontalGap) / (_columnWidth + explicitHorizontalGap)));
-            else
-                _columnCount = 1;
-        }
-        else if (!isNaN(height) && (orientation == TileOrientation.COLUMNS || isNaN(width)))
-        {
-            if (_rowHeight + explicitVerticalGap > 0)
-                _rowCount = Math.max(1, Math.floor((height + explicitVerticalGap) / (_rowHeight + explicitVerticalGap)));
-            else
-                _rowCount = 1;
-        }
-        else // Figure out the number of columns and rows so that pixels area occupied is as square as possible
-        {
-            // Calculate number of rows and columns so that
-            // pixel area is as square as possible
-            var hGap:Number = explicitHorizontalGap;
-            var vGap:Number = explicitVerticalGap;
-
-            // 1. columnCount * (columnWidth + hGap) - hGap == rowCount * (rowHeight + vGap) - vGap
-            // 1. columnCount * (columnWidth + hGap) == rowCount * (rowHeight + vGap) + hGap - vGap
-            // 1. columnCount == (rowCount * (rowHeight + vGap) + hGap - vGap) / (columnWidth + hGap)
-            // 2. columnCount * rowCount == elementCount
-            // substitute 1. in 2.
-            // rowCount * rowCount + (hGap - vGap) * rowCount - elementCount * (columnWidth + hGap ) == 0
-
-            var a:Number = Math.max(0, (rowHeight + vGap));
-            var b:Number = (hGap - vGap);
-            var c:Number = -elementCount * (_columnWidth + hGap);
-            var d:Number = b * b - 4 * a * c; // Always guaranteed to be greater than zero, since c <= 0
-            d = Math.sqrt(d);
-
-            // We are guaranteed that we have only one positive root, since d >= b:
-            var rowCount:Number = (a != 0) ? (b + d) / (2 * a) : elementCount;
-
-            // To get integer count for the columns/rows we round up and down so
-            // we get four possible solutions. Then we pick the best one.
-            var row1:int = Math.max(1, Math.floor(rowCount));
-            var col1:int = Math.max(1, Math.ceil(elementCount / row1));
-            row1 = Math.max(1, Math.ceil(elementCount / col1));
-
-            var row2:int = Math.max(1, Math.ceil(rowCount));
-            var col2:int = Math.max(1, Math.ceil(elementCount / row2));
-            row2 = Math.max(1, Math.ceil(elementCount / col2));
-
-            var col3:int = Math.max(1, Math.floor(elementCount / rowCount));
-            var row3:int = Math.max(1, Math.ceil(elementCount / col3));
-            col3 = Math.max(1, Math.ceil(elementCount / row3));
-
-            var col4:int = Math.max(1, Math.ceil(elementCount / rowCount));
-            var row4:int = Math.max(1, Math.ceil(elementCount / col4));
-            col4 = Math.max(1, Math.ceil(elementCount / row4));
-
-            if (closerToSquare(col3, row3, col1, row1))
-            {
-                col1 = col3;
-                row1 = row3;
-            }
-
-            if (closerToSquare(col4, row4, col2, row2))
-            {
-                col2 = col4;
-                row2 = row4;
-            }
-
-            if (closerToSquare(col1, row1, col2, row2))
-            {
-                _columnCount = col1;
-                _rowCount = row1;
-            }
-            else
-            {
-                _columnCount = col2;
-                _rowCount = row2;
-            }
-        }
-
-        // In case we determined only columns or rows (from explicit overrides or explicit width/height)
-        // calculate the other from the number of elements
-        if (-1 == _rowCount)
-            _rowCount = Math.max(1, Math.ceil(elementCount / _columnCount));
-        if (-1 == _columnCount)
-            _columnCount = Math.max(1, Math.ceil(elementCount / _rowCount));
-    } */
-
-    /**
-     *  @private
-     *  Increases the gap so that elements are justified to exactly fit totalSize
-     *  leaving no partially visible elements in view.
-     *  @return Returs the new gap size.
-     */
-    /* private function justifyByGapSize(totalSize:Number, elementSize:Number,
-                                      gap:Number, elementCount:int):Number
-    {
-        // If element + gap collapses to zero, then don't adjust the gap.
-        if (elementSize + gap <= 0)
-            return gap;
-
-        // Find the number of fully visible elements
-        var visibleCount:int =
-            Math.min(elementCount, Math.floor((totalSize + gap) / (elementSize + gap)));
-
-        // If there isn't even a singel fully visible element, don't adjust the gap
-        if (visibleCount < 1)
-            return gap;
-
-        // Special case: if there's a singe fully visible element and a partially
-        // visible element, then make the gap big enough to push out the partially
-        // visible element out of view.
-        if (visibleCount == 1)
-            return elementCount > 1 ? Math.max(gap, totalSize - elementSize) : gap;
-
-        // Now calculate the gap such that the fully visible elements and gaps
-        // add up exactly to totalSize:
-        // <==> totalSize == visibleCount * elementSize + (visibleCount - 1) * gap
-        // <==> totalSize - visibleCount * elementSize == (visibleCount - 1) * gap
-        // <==> (totalSize - visibleCount * elementSize) / (visibleCount - 1) == gap
-        return (totalSize - visibleCount * elementSize) / (visibleCount - 1);
-    } */
-
-    /**
-     *  @private
-     *  Increases the element size so that elements are justified to exactly fit
-     *  totalSize leaving no partially visible elements in view.
-     *  @return Returns the the new element size.
-     */
-    /* private function justifyByElementSize(totalSize:Number, elementSize:Number,
-                                          gap:Number, elementCount:int):Number
-    {
-        var elementAndGapSize:Number = elementSize + gap;
-        var visibleCount:int = 0;
-        // Find the number of fully visible elements
-        if (elementAndGapSize == 0)
-            visibleCount = elementCount;
-        else
-            visibleCount = Math.min(elementCount, Math.floor((totalSize + gap) / elementAndGapSize));
-
-        // If there isn't event a single fully visible element, don't adjust
-        if (visibleCount < 1)
-            return elementSize;
-
-        // Now calculate the elementSize such that the fully visible elements and gaps
-        // add up exactly to totalSize:
-        // <==> totalSize == visibleCount * elementSize + (visibleCount - 1) * gap
-        // <==> totalSize - (visibleCount - 1) * gap == visibleCount * elementSize
-        // <==> (totalSize - (visibleCount - 1) * gap) / visibleCount == elementSize
-        return (totalSize - (visibleCount - 1) * gap) / visibleCount;
-    } */
-
-    /**
-     *  @private
-     *  Update _tileWidth,Height to be the maximum of their current
-     *  value and the element's preferred bounds. 
-     */
-    /* private function updateVirtualTileSize(elt:ILayoutElement):void
-    {
-        if (!elt || !elt.includeInLayout)
-            return;
-        var w:Number = elt.getPreferredBoundsWidth();
-        var h:Number = elt.getPreferredBoundsHeight();
-        _tileWidthCached = isNaN(_tileWidthCached) ? w : Math.max(w, _tileWidthCached);
-        _tileHeightCached = isNaN(_tileHeightCached) ? h : Math.max(h, _tileHeightCached);
-    } */
-    
-    /**
-     *  @private
-     */
-   /*  private function calculateVirtualTileSize():void
-    {
-        // If both dimensions are explicitly set, we're done
-        _columnWidth = explicitColumnWidth;
-        _rowHeight = explicitRowHeight;
-        if (!isNaN(_columnWidth) && !isNaN(_rowHeight))
-        {
-            _tileWidthCached = _columnWidth;
-            _tileHeightCached = _rowHeight;
-            return;
-        }
-        
-        // update _tileWidth,HeightCached based on the typicalElement     
-        updateVirtualTileSize(typicalLayoutElement);
-        
-        // update _tileWidth,HeightCached based on visible elements    
-        if ((visibleStartIndex != -1) && (visibleEndIndex != -1))
-        {
-            for (var index:int = visibleStartIndex; index <= visibleEndIndex; index++)
-                updateVirtualTileSize(target.getVirtualElementAt(index));
-        }
-        
-        // Make sure that we always have non-NaN values in the cache, even
-        // when there are no elements.
-        if (isNaN(_tileWidthCached))
-            _tileWidthCached = 0;
-        if (isNaN(_tileHeightCached))
-            _tileHeightCached = 0;
-        
-        if (isNaN(_columnWidth))
-            _columnWidth = _tileWidthCached;
-        if (isNaN(_rowHeight))
-            _rowHeight = _tileHeightCached;        
-    } */
-
-    /**
-     *  @private
-     *  Calculates _columnWidth and _rowHeight from maximum of
-     *  elements preferred size and any explicit overrides.
-     */
-    /* private function calculateRealTileSize():void
-    {
-        _columnWidth = _tileWidthCached;
-        _rowHeight = _tileHeightCached;
-        if (!isNaN(_columnWidth) && !isNaN(_rowHeight))
-            return;
-
-        // Are both dimensions explicitly set?
-        _columnWidth = _tileWidthCached = explicitColumnWidth;
-        _rowHeight = _tileHeightCached = explicitRowHeight;
-        if (!isNaN(_columnWidth) && !isNaN(_rowHeight))
-            return;
-
-        // Find the maxmimums of element's preferred sizes
-        var columnWidth:Number = 0;
-        var rowHeight:Number = 0;
-
-        var layoutTarget:GroupBase = target;
-        var count:int = layoutTarget.numElements;
-        // Remember the number of includeInLayout elements
-        _numElementsCached = count;
-        for (var i:int = 0; i < count; i++)
-        {
-            var el:ILayoutElement = layoutTarget.getElementAt(i);
-            if (!el || !el.includeInLayout)
-            {
-                _numElementsCached--;
-                continue;
-            }
-
-            if (isNaN(_columnWidth))
-                columnWidth = Math.max(columnWidth, el.getPreferredBoundsWidth());
-            if (isNaN(_rowHeight))
-                rowHeight = Math.max(rowHeight, el.getPreferredBoundsHeight());
-        }
-
-        if (isNaN(_columnWidth))
-            _columnWidth = _tileWidthCached = columnWidth;
-        if (isNaN(_rowHeight))
-            _rowHeight = _tileHeightCached = rowHeight;
-    } */
-    
-    /* private function calculateTileSize():void    
-    {
-        if (useVirtualLayout)
-            calculateVirtualTileSize();
-        else 
-            calculateRealTileSize();
-    }  */   
-
-    /**
-     *  @private
-     *  For normal layout return the number of non-null includeInLayout=true
-     *  layout elements, for virtual layout just return the number of layout
-     *  elements.
-     */
-   /*  private function calculateElementCount():int
-    {
-        if (-1 != _numElementsCached)
-            return _numElementsCached;
-            
-        var layoutTarget:GroupBase = target;
-        var count:int = layoutTarget.numElements;
-        _numElementsCached = count;
-
-        if (useVirtualLayout)
-            return _numElementsCached;
-            
-        for (var i:int = 0; i < count; i++)
-        {
-            var el:ILayoutElement = layoutTarget.getElementAt(i);
-            if (!el || !el.includeInLayout)
-                _numElementsCached--;
-        }
-
-        return _numElementsCached;
-    } */
-    
-    /**
-     *  @private
-     *  This method computes values for visibleStartX,Y, visibleStartIndex, and 
-     *  visibleEndIndex based on the TileLayout geometry values, like _columnWidth
-     *  and _rowHeight, computed by calculateActualValues().
-     * 
-     *  If useVirtualLayout=false, then visibleStartX,Y=0 and visibleStartIndex=0
-     *  and visibleEndIndex=layoutTarget.numElements-1.
-     * 
-     *  If useVirtualLayout=true and orientation=ROWS then visibleStartIndex is the 
-     *  layout element index of the item at first visible row relative to the scrollRect, 
-     *  column 0.  Note that we're using column=0 instead of the first visible column
-     *  to simplify the iteration logic in updateDisplayList().  This is optimal 
-     *  for the common case where the entire row is visible.   Optimally handling 
-     *  the case where orientation=ROWS and each row is only partially visible is 
-     *  doable but adds some complexity to the main loop.
-     * 
-     *  The logic for useVirtualLayout=true and orientation=COLS is similar.
-     */
-    /* private function calculateDisplayParameters(unscaledWidth:int, unscaledHeight:int):void
-    {
-        updateActualValues(unscaledWidth, unscaledHeight);
-
-        var layoutTarget:GroupBase = target;
-        var eltCount:int = layoutTarget.numElements;
-        visibleStartX = paddingLeft;   // initial values for xPos,yPos in updateDisplayList
-        visibleStartY = paddingTop;
-        visibleStartIndex = 0;
-        visibleEndIndex = eltCount - 1;
-
-        if (useVirtualLayout)
-        {
-            var hsp:Number = layoutTarget.horizontalScrollPosition - paddingLeft;
-            var vsp:Number = layoutTarget.verticalScrollPosition - paddingTop;
-            var cwg:Number = _columnWidth + _horizontalGap;
-            var rwg:Number = _rowHeight + _verticalGap;
-            
-            var visibleCol0:int = Math.max(0, Math.floor(hsp / cwg));
-            var visibleRow0:int = Math.max(0, Math.floor(vsp / rwg));
-            var visibleCol1:int = Math.min(_columnCount - 1, Math.floor((hsp + unscaledWidth) / cwg));
-            var visibleRow1:int = Math.min(_rowCount - 1, Math.floor((vsp + unscaledHeight) / rwg));
-
-            if (orientation == TileOrientation.ROWS)
-            {
-                visibleStartIndex = (visibleRow0 * _columnCount);
-                visibleEndIndex = Math.min(eltCount - 1, (visibleRow1 * _columnCount) + visibleCol1); 
-                visibleStartY = visibleRow0 * rwg + paddingTop;
-            }
-            else
-            {
-                visibleStartIndex = (visibleCol0 * _rowCount);
-                visibleEndIndex = Math.min(eltCount - 1, (visibleCol1 * _rowCount) + visibleRow1);
-                visibleStartX = visibleCol0 * cwg + paddingLeft;       
-            }
-        }
-    } */
-    
-    /**
-     *  @private
-     *  This method is called by updateDisplayList() after initial values for 
-     *  visibleStartIndex, visibleEndIndex have been calculated.  We 
-     *  re-calculateDisplayParameters() to account for the possibility that
-     *  larger cells may have been exposed.  Since tileWidth,Height can only
-     *  increase, the new visibleStart,EndIndex values will be greater than or
-     *  equal to the old ones. 
-     */
-     /* private function updateVirtualLayout(unscaledWidth:int, unscaledHeight:int):void
-     {
-        var oldVisibleStartIndex:int = visibleStartIndex;
-        var oldVisibleEndIndex:int = visibleEndIndex;
-        calculateDisplayParameters(unscaledWidth, unscaledHeight);  // compute new visibleStart,EndIndex values
-        
-        // We're responsible for laying out *all* of the elements requested
-        // with getVirtualElementAt(), even if they don't fall within the final
-        // visible range.  Hide any extra ones.  On the next layout pass, they'll
-        // be added to DataGroup::freeRenderers
-        
-        var layoutTarget:GroupBase = target;
-        for (var i:int = oldVisibleStartIndex; i <= oldVisibleEndIndex; i++)
-        {
-            if ((i >= visibleStartIndex) && (i <= visibleEndIndex)) // skip past the visible range
-            {
-                i = visibleEndIndex;
-                continue;
-            } 
-            var el:ILayoutElement = layoutTarget.getElementAt(i);
-            if (!el)
-                continue;
-            if (el is IVisualElement)
-                IVisualElement(el).visible = false; 
-        }
-     }     */
-
-    /**
-     *  Sets the size and the position of the specified layout element and cell bounds.
-     *  @param element - the element to resize and position.
-     *  @param cellX - the x coordinate of the cell.
-     *  @param cellY - the y coordinate of the cell.
-     *  @param cellWidth - the width of the cell.
-     *  @param cellHeight - the height of the cell.
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* private function sizeAndPositionElement(element:ILayoutElement,
-                                              cellX:int,
-                                              cellY:int,
-                                              cellWidth:int,
-                                              cellHeight:int):void
-    {
-        var childWidth:Number = NaN;
-        var childHeight:Number = NaN;
-
-        // Determine size of the element
-        if (horizontalAlign == "justify")
-            childWidth = cellWidth;
-        else if (!isNaN(element.percentWidth))
-            childWidth = Math.round(cellWidth * element.percentWidth * 0.01);
-        else
-            childWidth = element.getPreferredBoundsWidth();
-
-        if (verticalAlign == "justify")
-            childHeight = cellHeight;
-        else if (!isNaN(element.percentHeight))
-            childHeight = Math.round(cellHeight * element.percentHeight * 0.01);
-        else
-            childHeight = element.getPreferredBoundsHeight();
-
-        // Enforce min and max limits
-        var maxChildWidth:Number = Math.min(element.getMaxBoundsWidth(), cellWidth);
-        var maxChildHeight:Number = Math.min(element.getMaxBoundsHeight(), cellHeight);
-        // Make sure we enforce element's minimum last, since it has the highest priority
-        childWidth = Math.max(element.getMinBoundsWidth(), Math.min(maxChildWidth, childWidth));
-        childHeight = Math.max(element.getMinBoundsHeight(), Math.min(maxChildHeight, childHeight));
-
-        // Size the element
-        element.setLayoutBoundsSize(childWidth, childHeight);
-
-        var x:Number = cellX;
-        switch (horizontalAlign)
-        {
-            case "right":
-                x += cellWidth - element.getLayoutBoundsWidth();
-            break;
-            case "center":
-                // Make sure division result is integer - Math.floor() the result.
-                x = cellX + Math.floor((cellWidth - element.getLayoutBoundsWidth()) / 2);
-            break;
-        }
-
-        var y:Number = cellY;
-        switch (verticalAlign)
-        {
-            case "bottom":
-                y += cellHeight - element.getLayoutBoundsHeight();
-            break;
-            case "middle":
-                // Make sure division result is integer - Math.floor() the result.
-                y += Math.floor((cellHeight - element.getLayoutBoundsHeight()) / 2);
-            break;
-        }
-
-        // Position the element
-        element.setLayoutBoundsPosition(x, y);
-    } */
-
-    /**
-     *  @private
-     *  @return Returns the x coordinate of the left edge for the specified column.
-     */
-    /* final private function leftEdge(columnIndex:int):Number
-    {
-        if (columnIndex < 0)
-            return 0;
-        
-        return Math.max(0, columnIndex * (_columnWidth + _horizontalGap)) + paddingLeft;
-    } */
-
-    /**
-     *  @private
-     *  @return Returns the x coordinate of the right edge for the specified column.
-     */
-    /* final private function rightEdge(columnIndex:int):Number
-    {
-        if (columnIndex < 0)
-            return 0;
-        
-        return Math.min(target.contentWidth, columnIndex * (_columnWidth + _horizontalGap) + _columnWidth) + paddingLeft;
-    } */
-
-    /**
-     *  @private
-     *  @return Returns the y coordinate of the top edge for the specified row.
-     */
-    /* final private function topEdge(rowIndex:int):Number
-    {
-        if (rowIndex < 0)
-            return 0;
-        
-        return Math.max(0, rowIndex * (_rowHeight + _verticalGap)) + paddingTop;
-    } */
-
-    /**
-     *  @private
-     *  @return Returns the y coordinate of the bottom edge for the specified row.
-     */
-    /* final private function bottomEdge(rowIndex:int):Number
-    {
-        if (rowIndex < 0)
-            return 0;
-        
-        return Math.min(target.contentHeight, rowIndex * (_rowHeight + _verticalGap) + _rowHeight) + paddingTop;
-    } */
-    
-    /**
-     *  @private 
-     *  Convenience function for subclasses that invalidates the
-     *  target's size and displayList so that both layout's <code>measure()</code>
-     *  and <code>updateDisplayList</code> methods get called.
-     * 
-     *  <p>Typically a layout invalidates the target's size and display list so that
-     *  it gets a chance to recalculate the target's default size and also size and
-     *  position the target's elements. For example changing the <code>gap</code>
-     *  property on a <code>VerticalLayout</code> will internally call this method
-     *  to ensure that the elements are re-arranged with the new setting and the
-     *  target's default size is recomputed.</p> 
-     */
-    /* private function invalidateTargetSizeAndDisplayList():void
-    {
-        var g:GroupBase = target;
-        if (!g)
-            return;
-
-        g.invalidateSize();
-        g.invalidateDisplayList();
-    } */
-
-    //--------------------------------------------------------------------------
-    //
-    //  Overridden methods from LayoutBase
-    //
-    //--------------------------------------------------------------------------
-
-    /**
-     *  @private
-     */
-    /* override protected function scrollPositionChanged():void
-    {
-        super.scrollPositionChanged();
-        
-        var layoutTarget:GroupBase = target;
-        if (!layoutTarget)
-            return;
-
-        if (useVirtualLayout)
-            layoutTarget.invalidateDisplayList();
-    } */
-
-    /**
-     *  @private
-     */
-    /* override public function measure():void
-    {
-        // Save and restore these values so they're not modified 
-        // as a sideeffect of measure().
-        var savedColumnCount:int = _columnCount;
-        var savedRowCount:int = _rowCount;
-        var savedHorizontalGap:int = _horizontalGap;
-        var savedVerticalGap:int = _verticalGap;
-        var savedColumnWidth:int = _columnWidth;
-        var savedRowHeight:int = _rowHeight; 
-
-        var layoutTarget:GroupBase = target;
-        if (!layoutTarget)
-            return;
-            
-        updateActualValues(layoutTarget.explicitWidth, layoutTarget.explicitHeight);
-
-        // For measure, any explicit overrides for rowCount and columnCount take precedence
-        var columnCount:int = _requestedColumnCount != -1 ? Math.max(1, _requestedColumnCount) : _columnCount;
-        var rowCount:int = _requestedRowCount != -1 ? Math.max(1, _requestedRowCount) : _rowCount;
-        
-        var measuredWidth:Number = 0;
-        var measuredMinWidth:Number = 0;
-        var measuredHeight:Number = 0;
-        var measuredMinHeight:Number = 0;
-        
-        if (columnCount > 0)
-        {
-            measuredWidth = Math.ceil(columnCount * (_columnWidth + _horizontalGap) - _horizontalGap)
-            // measured min size is guaranteed to have enough columns to fit all elements
-            measuredMinWidth = Math.ceil(_columnCount * (_columnWidth + _horizontalGap) - _horizontalGap);
-        }
-            
-        if (rowCount > 0)
-        {
-            measuredHeight = Math.ceil(rowCount * (_rowHeight + _verticalGap) - _verticalGap);
-            // measured min size is guaranteed to have enough rows to fit all elements
-            measuredMinHeight = Math.ceil(_rowCount * (_rowHeight + _verticalGap) - _verticalGap);
-        }
-		_numElementsCached = -1;
-        
-        var hPadding:Number = paddingLeft + paddingRight;
-        var vPadding:Number = paddingTop + paddingBottom;
-
-        layoutTarget.measuredWidth = measuredWidth + hPadding;
-        layoutTarget.measuredMinWidth = measuredMinWidth + hPadding;
-        layoutTarget.measuredHeight = measuredHeight + vPadding;
-        layoutTarget.measuredMinHeight = measuredMinHeight + vPadding;
-
-        _columnCount = savedColumnCount;
-        _rowCount = savedRowCount;
-        _horizontalGap = savedHorizontalGap;
-        _verticalGap = savedVerticalGap;
-        _columnWidth = savedColumnWidth;
-        _rowHeight = savedRowHeight; 
-    } */
-
-    /**
-     *  @private 
-     */  
-    /* override public function getNavigationDestinationIndex(currentIndex:int, navigationUnit:uint, arrowKeysWrapFocus:Boolean):int
-    {
-        if (!target || target.numElements < 1)
-            return -1; 
-            
-        var maxIndex:int = target.numElements - 1;
-
-        // Special case when nothing was previously selected
-        if (currentIndex == -1)
-        {
-            if (navigationUnit == NavigationUnit.UP || navigationUnit == NavigationUnit.LEFT)
-                return arrowKeysWrapFocus ? maxIndex : -1;
-
-            if (navigationUnit == NavigationUnit.DOWN || navigationUnit == NavigationUnit.RIGHT)
-                return 0;    
-        }    
-            
-        // Make sure currentIndex is within range
-        var inRows:Boolean = orientation == TileOrientation.ROWS;
-        currentIndex = Math.max(0, Math.min(maxIndex, currentIndex));
-
-        // Find the current column and row
-        var currentRow:int;
-        var currentColumn:int;
-        if (inRows)
-        {
-            // Is the TileLayout initialized with valid values?
-            if (columnCount == 0 || rowHeight + verticalGap == 0)
-                return currentIndex;
-                    
-            currentRow = currentIndex / columnCount;
-            currentColumn = currentIndex - currentRow * columnCount;
-        }
-        else
-        {
-            // Is the TileLayout initialized with valid values?
-            if (rowCount == 0 || columnWidth + horizontalGap == 0)
-                return currentIndex;
-    
-            currentColumn = currentIndex / rowCount;
-            currentRow = currentIndex - currentColumn * rowCount;
-        }
-        
-        var newRow:int = currentRow;
-        var newColumn:int = currentColumn;
-
-        // Handle user input, almost all range checks are
-        // performed after the calculations, at the end of the method.
-        switch (navigationUnit)
-        {
-            case NavigationUnit.LEFT: 
-            {
-                // If we are at the first column, can
-                // we go to the previous element (last column, previous row)?
-                if (newColumn == 0 && inRows && newRow > 0)
-                {
-                    newRow--;
-                    newColumn = columnCount - 1;
-                }
-                else if (arrowKeysWrapFocus && newColumn == 0 && inRows && newRow == 0)
-                {
-                    newRow = rowCount - 1;
-                    newColumn = columnCount - 1;
-                }
-                else
-                    newColumn--;
-                break;
-            }
-
-            case NavigationUnit.RIGHT:
-            {
-                // If we are at the last column, can
-                // we go to the next element (first column, next row)?
-                if (newColumn == columnCount - 1 && inRows && newRow < rowCount - 1)
-                {
-                    newColumn = 0;
-                    newRow++;
-                }
-                else if (arrowKeysWrapFocus && newColumn == columnCount - 1 && inRows && newRow == rowCount - 1)
-                {
-                    newColumn = 0;
-                    newRow = 0;
-                }
-                else
-                    newColumn++;
-                break;
-            } 
-
-            case NavigationUnit.UP:
-            {
-                // If we are at the first row, can we
-                // go to the previous element (previous column, last row)?
-                if (newRow == 0 && !inRows && newColumn > 0)
-                {
-                    newColumn--;
-                    newRow = rowCount - 1;
-                }
-                else if (arrowKeysWrapFocus && newRow == 0 && !inRows && newColumn == 0)
-                {
-                    newColumn = columnCount - 1;
-                    newRow = rowCount - 1;
-                }
-                else
-                    newRow--;
-                break; 
-            }
-
-            case NavigationUnit.DOWN:
-            {
-                // If we are at the last row, can we
-                // go to the next element (next column, first row)?
-                if (newRow == rowCount - 1 && !inRows && newColumn < columnCount - 1)
-                {
-                    newColumn++;
-                    newRow = 0;
-                }
-                else if (arrowKeysWrapFocus && newRow == rowCount - 1 && !inRows && newColumn == columnCount - 1)
-                {
-                    newColumn = 0;
-                    newRow = 0;
-                }
-                else
-                    newRow++;
-                break; 
-            }
-
-            case NavigationUnit.PAGE_UP:
-            case NavigationUnit.PAGE_DOWN:
-            {
-                // Ensure we have a valid scrollRect as we use it for calculations below
-                var scrollRect:Rectangle = getScrollRect();
-                if (!scrollRect)
-                    scrollRect = new Rectangle(0, 0, target.contentWidth, target.contentHeight);
-                 
-                if (inRows)
-                {
-                    var firstVisibleRow:int = Math.ceil(scrollRect.top / (rowHeight + verticalGap));
-                    var lastVisibleRow:int = Math.floor(scrollRect.bottom / (rowHeight + verticalGap));
-                     
-                    if (navigationUnit == NavigationUnit.PAGE_UP)
-                    {
-                        // Is the current row visible, somewhere in the middle of the scrollRect?
-                        if (firstVisibleRow < currentRow && currentRow <= lastVisibleRow)
-                            newRow = firstVisibleRow;
-                        else                             
-                            newRow = 2 * firstVisibleRow - lastVisibleRow;
-                    } 
-                    else
-                    {
-                        // Is the current row visible, somewhere in the middle of the scrollRect?
-                        if (firstVisibleRow <= currentRow && currentRow < lastVisibleRow)
-                            newRow = lastVisibleRow;
-                        else                             
-                            newRow = 2 * lastVisibleRow - firstVisibleRow;
-                    }
-                }
-                else
-                {
-                    var firstVisibleColumn:int = Math.ceil(scrollRect.left / (columnWidth + horizontalGap));
-                    var lastVisibleColumn:int = Math.floor(scrollRect.right / (columnWidth + horizontalGap));
-                    
-                    if (navigationUnit == NavigationUnit.PAGE_UP)
-                    {
-                        // Is the current column visible, somewhere in the middle of the scrollRect?
-                        if (firstVisibleColumn < currentColumn && currentColumn <= lastVisibleColumn)
-                            newColumn = firstVisibleColumn;
-                        else    
-                            newColumn = 2 * firstVisibleColumn - lastVisibleColumn; 
-                    }
-                    else
-                    {
-                        // Is the current column visible, somewhere in the middle of the scrollRect?
-                        if (firstVisibleColumn <= currentColumn && currentColumn < lastVisibleColumn)
-                            newColumn = lastVisibleColumn;
-                        else    
-                            newColumn = 2 * lastVisibleColumn - firstVisibleColumn;
-                    }
-                }
-                break; 
-            }
-            default: return super.getNavigationDestinationIndex(currentIndex, navigationUnit, arrowKeysWrapFocus);
-        }
-
-        // Make sure rows and columns are within range
-        newRow = Math.max(0, Math.min(rowCount - 1, newRow));
-        newColumn = Math.max(0, Math.min(columnCount - 1, newColumn));
-
-        // Calculate the new index based on orientation        
-        if (inRows)  
-        {
-            // Make sure we don't return an index for an empty space in the last row.
-            // newRow is guaranteed to be greater than zero:
-            
-            if (newRow == rowCount - 1)
-            {
-                // Step 1: We can end up at the empty space in the last row if we moved right from
-                // the last item.
-                if (currentIndex == maxIndex && newColumn > currentColumn)
-                    newColumn = currentColumn;
-                    
-                // Step 2: We can end up at the empty space in the last row if we moved down from
-                // the previous row.    
-                if (newColumn > maxIndex - columnCount * (rowCount - 1))
-                    newRow--;
-            }
-
-            return newRow * columnCount + newColumn;
-        }
-        else
-        {
-            // Make sure we don't return an index for an empty space in the last column.
-            // newColumn is guaranteed to be greater than zero:
-            
-            if (newColumn == columnCount - 1)
-            {
-                // Step 1: We can end up at the empty space in the last column if we moved down from
-                // the last item.
-                if (currentIndex == maxIndex && newRow > currentRow)
-                    newRow = currentRow;
-                
-                // Step 2: We can end up at the empty space in the last column if we moved right from
-                // the previous column.    
-                if (newRow > maxIndex - rowCount * (columnCount - 1))
-                    newColumn--;
-            }
-
-            return newColumn * rowCount + newRow;
-        }
-    } */
-
-    /**
-     *  @private
-     */
-    /* override public function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
-    {
-        var layoutTarget:GroupBase = target;
-        if (!layoutTarget)
-            return;
-
-        calculateDisplayParameters(unscaledWidth, unscaledHeight);
-        if (useVirtualLayout)
-            updateVirtualLayout(unscaledWidth, unscaledHeight);  // re-calculateDisplayParameters()
-        
-        // Upper right hand corner of first (visibleStartIndex) tile/cell
-        var xPos:Number = visibleStartX;  // paddingLeft if useVirtualLayout=false
-        var yPos:Number = visibleStartY;  // paddingTop if useVirtualLayout=false
-                
-        // Use MajorDelta when moving along the major axis
-        var xMajorDelta:Number;
-        var yMajorDelta:Number;
-
-        // Use MinorDelta when moving along the minor axis
-        var xMinorDelta:Number;
-        var yMinorDelta:Number;
-
-        // Use counter and counterLimit to track when to move along the minor axis
-        var counter:int = 0;
-        var counterLimit:int;
-
-        // Setup counterLimit and deltas based on orientation
-        if (orientation == TileOrientation.ROWS)
-        {
-            counterLimit = _columnCount;
-            xMajorDelta = _columnWidth + _horizontalGap;
-            xMinorDelta = 0;
-            yMajorDelta = 0;
-            yMinorDelta = _rowHeight + _verticalGap;
-        }
-        else
-        {
-            counterLimit = _rowCount;
-            xMajorDelta = 0;
-            xMinorDelta = _columnWidth + _horizontalGap;
-            yMajorDelta = _rowHeight + _verticalGap;
-            yMinorDelta = 0;
-        }
-
-        for (var index:int = visibleStartIndex; index <= visibleEndIndex; index++)
-        {
-            var el:ILayoutElement = null; 
-            if (useVirtualLayout)
-            {
-                el = layoutTarget.getVirtualElementAt(index);
-                if (el is IVisualElement)  // see updateVirtualLayout
-                    IVisualElement(el).visible = true; 
-            }
-            else
-                el = layoutTarget.getElementAt(index);
-
-            if (!el || !el.includeInLayout)
-                continue;
-
-            // To calculate the cell extents as integers, first calculate
-            // the extents and then use Math.round()
-            var cellX:int = Math.round(xPos);
-            var cellY:int = Math.round(yPos);
-            var cellWidth:int = Math.round(xPos + _columnWidth) - cellX;
-            var cellHeight:int = Math.round(yPos + _rowHeight) - cellY;
-
-            sizeAndPositionElement(el, cellX, cellY, cellWidth, cellHeight);
-
-            // Move along the major axis
-            xPos += xMajorDelta;
-            yPos += yMajorDelta;
-
-            // Move along the minor axis
-            if (++counter >= counterLimit)
-            {
-                counter = 0;
-                if (orientation == TileOrientation.ROWS)
-                {
-                    xPos = paddingLeft;
-                    yPos += yMinorDelta;
-                }
-                else
-                {
-                    xPos += xMinorDelta;
-                    yPos = paddingTop;
-                }
-            }
-        }
-
-        var hPadding:Number = paddingLeft + paddingRight;
-        var vPadding:Number = paddingTop + paddingBottom;
-        
-        // Make sure that if the content spans partially over a pixel to the right/bottom,
-        // the content size includes the whole pixel.
-        layoutTarget.setContentSize(Math.ceil(_columnCount * (_columnWidth + _horizontalGap) - _horizontalGap) + hPadding,
-                                    Math.ceil(_rowCount * (_rowHeight + _verticalGap) - _verticalGap) + vPadding);
-
-        // Reset the cache
-        if (!useVirtualLayout)
-            _tileWidthCached = _tileHeightCached = NaN;
-        _numElementsCached = -1;
-        
-        // No getVirtualElementAt() during measure, see calculateVirtualTileSize()
-        if (useVirtualLayout)
-            visibleStartIndex = visibleEndIndex = -1;        
-
-        // If actual values have chnaged, notify listeners
-        dispatchEventsForActualValueChanges();
-    } */
-
-    /**
-     *  @private
-     */
-    /* override public function getElementBounds(index:int):Rectangle
-    {
-        if (!useVirtualLayout)
-            return super.getElementBounds(index);
-
-        var g:GroupBase = GroupBase(target);
-        if (!g || (index < 0) || (index >= g.numElements)) 
-            return null;
-
-        var col:int;
-        var row:int;
-        if (orientation == TileOrientation.ROWS)
-        {
-            col = index % _columnCount;
-            row = index / _columnCount;
-        }
-        else
-        {
-            col = index / _rowCount;
-            row = index % _rowCount
-        }
-        return new Rectangle(leftEdge(col), topEdge(row), _columnWidth, _rowHeight);
-    } */
-
-    /**
-     *  @private
-     */
-    /* override protected function getElementBoundsLeftOfScrollRect(scrollRect:Rectangle):Rectangle
-    {
-        var bounds:Rectangle = new Rectangle();
-        // Find the column that spans or is to the left of the scrollRect left edge.
-        var column:int = Math.floor((scrollRect.left - 1 - paddingLeft) / (_columnWidth + _horizontalGap));
-        bounds.left = leftEdge(column);
-        bounds.right = rightEdge(column);
-        return bounds;
-    } */
-
-    /**
-     *  @private
-     */
-    /* override protected function getElementBoundsRightOfScrollRect(scrollRect:Rectangle):Rectangle
-    {
-        var bounds:Rectangle = new Rectangle();
-        // Find the column that spans or is to the right of the scrollRect right edge.
-        var column:int = Math.floor(((scrollRect.right + 1 + _horizontalGap) - paddingLeft) / (_columnWidth + _horizontalGap));
-        bounds.left = leftEdge(column);
-        bounds.right = rightEdge(column);
-        return bounds;
-    } */
-
-    /**
-     *  @private
-     */
-    /* override protected function getElementBoundsAboveScrollRect(scrollRect:Rectangle):Rectangle
-    {
-        var bounds:Rectangle = new Rectangle();
-        // Find the row that spans or is above the scrollRect top edge
-        var row:int = Math.floor((scrollRect.top - 1 - paddingTop) / (_rowHeight + _verticalGap));
-        bounds.top = topEdge(row);
-        bounds.bottom = bottomEdge(row);
-        return bounds;
-    } */
-
-    /**
-     *  @private
-     */
-    /* override protected function getElementBoundsBelowScrollRect(scrollRect:Rectangle):Rectangle
-    {
-        var bounds:Rectangle = new Rectangle();
-        // Find the row that spans or is below the scrollRect bottom edge
-        var row:int = Math.floor(((scrollRect.bottom + 1 + _verticalGap) - paddingTop) / (_rowHeight + _verticalGap));
-        bounds.top = topEdge(row);
-        bounds.bottom = bottomEdge(row);
-        return bounds;
-    } */
-    
-    /**
-     *  @private
-     */
-    /* override public function elementAdded(index:int):void
-    {
-        invalidateTargetSizeAndDisplayList();
-    } */
-    
-    /**
-     *  @private
-     */
-    /* override public function elementRemoved(index:int):void
-    {
-        invalidateTargetSizeAndDisplayList();
-    }   */   
-    
-    //--------------------------------------------------------------------------
-    //
-    //  Drop methods
-    //
-    //--------------------------------------------------------------------------
-    
-    /**
-     *  @private 
-     *  Calculates the column and row and returns the corresponding cell index.
-     *  Index may be out of range if there's no element for the cell.
-     */
-    /* private function calculateDropCellIndex(x:Number, y:Number):Array
-    {
-        var xStart:Number = x - paddingLeft;
-        var yStart:Number = y - paddingTop;
-        var column:int = Math.floor(xStart / (_columnWidth + _horizontalGap));
-        var row:int = Math.floor(yStart / (_rowHeight + _verticalGap));
-        
-        // Check whether x is closer to left column or right column:
-        var midColumnLine:Number;
-        var midRowLine:Number
-        
-        var rowOrientation:Boolean = orientation == TileOrientation.ROWS;
-        if (rowOrientation)
-        {
-            // Mid-line is at the middle of the cell
-            midColumnLine = (column + 1) * (_columnWidth + _horizontalGap) - _horizontalGap - _columnWidth / 2; 
-            
-            // Mid-line is at the middle of the gap between the rows
-            midRowLine = (row + 1) * (_rowHeight + _verticalGap) - _verticalGap / 2;  
-        }
-        else
-        {
-            // Mid-line is at the middle of the gap between the columns
-            midColumnLine = (column + 1) * (_columnWidth + _horizontalGap) - _horizontalGap / 2;
-            
-            // Mid-line is at the middle of the cell
-            midRowLine = (row + 1) * (_rowHeight + _verticalGap) - _verticalGap - _rowHeight / 2; 
-        }
-        
-        if (xStart > midColumnLine)
-            column++;
-        if (yStart > midRowLine)
-            row++;
-        
-        // Limit row and column, if any one is too far from the drop location
-        // And there is white space
-        if (column > _columnCount || row > _rowCount)
-        {
-            row = _rowCount;
-            column = _columnCount;
-        }
-
-        if (column < 0)
-            column = 0;
-        if (row < 0)
-            row = 0;
-        
-        if (rowOrientation)
-        {
-            if (row >= _rowCount)
-                row = _rowCount - 1;
-        }
-        else
-        {
-            if (column >= _columnCount)
-                column = _columnCount - 1;
-        }
-        return [row, column];
-    } */
-    
-    /**
-     *  @inheritDoc
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* override protected function calculateDropIndex(x:Number, y:Number):int
-    {
-        var result:Array = calculateDropCellIndex(x, y);
-        var row:int = result[0]; 
-        var column:int = result[1]; 
-        var index:int;
-
-        if (orientation == TileOrientation.ROWS)
-            index = row * _columnCount + column;
-        else
-            index = column * _rowCount + row;
-
-        var count:int = calculateElementCount();
-        _numElementsCached = -1; // Reset the cache
-
-        if (index > count)
-            index = count;
-        return index;
-    } */
-    
-    /**
-     *  @inheritDoc
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    /* override protected function calculateDropIndicatorBounds(dropLocation:DropLocation):Rectangle
-    {
-        var result:Array = calculateDropCellIndex(dropLocation.dropPoint.x, dropLocation.dropPoint.y);
-        var row:int = result[0]; 
-        var column:int = result[1]; 
-
-        var rowOrientation:Boolean = orientation == TileOrientation.ROWS;
-        var count:int = calculateElementCount();
-        _numElementsCached = -1; // Reset the cache
-        
-        if (rowOrientation)
-        {
-            // The last row may be only partially full,
-            // don't drop beyond the last column.
-            if (row * _columnCount + column > count)
-                column = count - (_rowCount - 1) * _columnCount;
-        }
-        else
-        {
-            // The last column may be only partially full,
-            // don't drop beyond the last row.
-            if (column * _rowCount + row > count)
-                row = count - (_columnCount - 1) * _rowCount;
-        }
-        
-        var x:Number;
-        var y:Number;
-        var dropIndicatorElement:IVisualElement;
-        var emptySpace:Number; // empty space between the elements
-
-        // Start with the dropIndicator dimensions, in case it's not 
-        // an IVisualElement
-        var width:Number = dropIndicator.width;
-        var height:Number = dropIndicator.height;
-
-        if (rowOrientation)
-        {
-            emptySpace = (0 < _horizontalGap ) ? _horizontalGap : 0; 
-            var emptySpaceLeft:Number = column * (_columnWidth + _horizontalGap) - emptySpace;
-            
-            // Special case - if we have negative gap and we're the last column,
-            // adjust the emptySpaceLeft
-            if (_horizontalGap < 0 && (column == _columnCount || count == dropLocation.dropIndex))
-                emptySpaceLeft -= _horizontalGap;
-
-            width = emptySpace;
-            height = _rowHeight;
-            // Special case - if we have negative gap and we're not the last
-            // row, adjust the height
-            if (_verticalGap < 0 && row < _rowCount - 1)
-                height += _verticalGap + 1;
-            
-            if (dropIndicator is IVisualElement)
-            {
-                dropIndicatorElement = IVisualElement(dropIndicator);
-                width = Math.max(Math.min(width,
-                                          dropIndicatorElement.getMaxBoundsWidth(false)),
-                                          dropIndicatorElement.getMinBoundsWidth(false));
-            }
-            
-            x = emptySpaceLeft + Math.round((emptySpace - width) / 2) + paddingLeft;
-            // Allow 1 pixel overlap with container border
-            x = Math.max(-1, Math.min(target.contentWidth - width + 1, x));
-
-            y = row * (_rowHeight + _verticalGap) + paddingTop;
-        }
-        else
-        {
-            emptySpace = (0 < _verticalGap ) ? _verticalGap : 0; 
-            var emptySpaceTop:Number = row * (_rowHeight + _verticalGap) - emptySpace;
-            
-            // Special case - if we have negative gap and we're the last column,
-            // adjust the emptySpaceLeft
-            if (_verticalGap < 0 && (row == _rowCount || count == dropLocation.dropIndex))
-                emptySpaceTop -= _verticalGap;
-
-            width = _columnWidth;
-            height = emptySpace;
-            // Special case - if we have negative gap and we're not the last
-            // column, adjust the width
-            if (_horizontalGap < 0 && column < _columnCount - 1)
-                width += _horizontalGap + 1;
-
-            if (dropIndicator is IVisualElement)
-            {
-                dropIndicatorElement = IVisualElement(dropIndicator);
-                height = Math.max(Math.min(emptySpace,
-                                           dropIndicatorElement.getMaxBoundsWidth(false)),
-                                           dropIndicatorElement.getMinBoundsWidth(false));
-            }
-
-            x = column * (_columnWidth + _horizontalGap) + paddingLeft;
-         
-            y = emptySpaceTop + Math.round((emptySpace - height) / 2) + paddingTop;
-            // Allow 1 pixel overlap with container border
-            y = Math.max(-1, Math.min(target.contentHeight - height + 1, y));
-        }
-        
-        return new Rectangle(x, y, width, height);
-    } */
-    
-    /**
-     *  @private
-     *  Helper function to return the row and column of the cell 
-     *  containing the x/y point.  The associated index may be out 
-     *  of range if there's no element for the cell.
-     */
-    /* private function calculateCellIndex(x:Number, y:Number):Array
-    {
-        var xStart:Number = x - paddingLeft;
-        var yStart:Number = y - paddingTop;
-        var column:int = Math.floor(xStart / (_columnWidth + _horizontalGap));
-        var row:int = Math.floor(yStart / (_rowHeight + _verticalGap));
-        
-        // Make sure column and row numbers are valid
-        if (column < 0)
-            column = 0;
-        if (column >= _columnCount)
-            column = _columnCount - 1;
-        if (row < 0)
-            row = 0;
-        if (row >= _rowCount)
-            row = _rowCount - 1;
-        
-        return [row, column];
-    } */
-    
-
-    /**
-     *  @private
-     *  Identifies the element which has its "compare point" located closest 
-     *  to the specified position.
-     */
-    /* override mx_internal function getElementNearestScrollPosition(
-        position:Point,
-        elementComparePoint:String = "center"):int
-    {
-        // Determine which cell contains the point        
-        var result:Array = calculateCellIndex(position.x, position.y);
-        var row:int = result[0]; 
-        var column:int = result[1]; 
-        
-        var maxRow:int = _rowCount-1; 
-        var maxColumn:int = _columnCount-1;
-        
-        // create a rectangle of the element bounds
-        var bounds:Rectangle = 
-            new Rectangle(leftEdge(column), topEdge(row), _columnWidth + _horizontalGap, _rowHeight + _verticalGap);
-
-        const TOP_LEFT:int = 0;
-        const TOP_RIGHT:int = 1;
-        const BOTTOM_LEFT:int = 2;
-        const BOTTOM_RIGHT:int = 3;
-        
-        // Determine the quadrant of the element/cell which contains the position point.
-        var quadrant:int = TOP_LEFT;
-        if (position.x > bounds.left + bounds.width/2)
-            quadrant += TOP_RIGHT;
-        if (position.y > bounds.top + bounds.height/2)
-            quadrant += BOTTOM_LEFT;
-        
-        var index:int;
-        if (orientation == TileOrientation.ROWS)
-            index = row * _columnCount + column;
-        else
-            index = column * _rowCount + row;
-        
-        var g:GroupBase = GroupBase(target);
-        if (index >= g.numElements)
-        {
-            // TODO (eday): two-dimensional item snapping will require more sophisticated cell detection
-            // if the position is beyond the content.  For now (while we only support one-dimensional
-            // snapping), using the last element will work fine.
-            return g.numElements - 1;
-        }
-        
-        // Depending on which point of the element is to be compared with, and on which 
-        // quadrant of the element contains the position, we may adjust row/column to
-        // points to an adjacent cell.
-        switch (elementComparePoint)
-        {
-            case "topLeft":
-                if (quadrant == TOP_RIGHT && column < maxColumn)
-                    column++;
-                else if (quadrant == BOTTOM_LEFT && row < maxRow)
-                    row++;
-                else if (quadrant == BOTTOM_RIGHT && row < maxRow && column < maxColumn)
-                {
-                    row++;
-                    column++;
-                }
-                break;
-            case "topRight":
-                if (quadrant == TOP_LEFT && column > 0)
-                    column--;
-                else if (quadrant == BOTTOM_LEFT && column > 0 && row < maxRow)
-                {
-                    column--;
-                    row++;
-                }
-                else if (quadrant == BOTTOM_RIGHT && row < maxRow)
-                    row++;
-                break;
-            case "bottomLeft":
-                if (quadrant == TOP_LEFT && row > 0)
-                    row--;
-                else if (quadrant == TOP_RIGHT && row > 0 && column < maxColumn)
-                {
-                    row--;
-                    column++;
-                }
-                else if (quadrant == BOTTOM_RIGHT && column < maxColumn)
-                    column++;
-                break;
-            case "bottomRight":
-                if (quadrant == TOP_LEFT && column > 0 && row > 0)
-                {
-                    column--;
-                    row--;
-                }
-                else if (quadrant == TOP_RIGHT && row > 0)
-                    row--;
-                else if (quadrant == BOTTOM_LEFT && column > 0)
-                    column--
-                break;
-            case "center":
-                // for center snapping, "index" is already always the cell with 
-                // its center closest to the specified position
-                break;
-        }
-
-        var newIndex:int;
-        if (orientation == TileOrientation.ROWS)
-            newIndex = row * _columnCount + column;
-        else
-            newIndex = column * _rowCount + row;
-        if (newIndex < g.numElements)
-            index = newIndex;
-        
-        return index;
-    } */
-
-}
-}
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.layouts
+{
+import org.apache.royale.geom.Point;
+import org.apache.royale.geom.Rectangle;
+
+import mx.core.ILayoutElement;
+import mx.core.IVisualElement;
+import mx.core.mx_internal;
+import mx.events.PropertyChangeEvent;
+
+import spark.components.supportClasses.GroupBase;
+import spark.core.NavigationUnit;
+import spark.layouts.supportClasses.DropLocation;
+import spark.layouts.supportClasses.LayoutBase;
+
+use namespace mx_internal;
+
+/**
+ *  The TileLayout class arranges layout elements in columns and rows
+ *  of equally-sized cells.
+ *  The TileLayout class uses a number of properties that control orientation,
+ *  count, size, gap and justification of the columns and the rows
+ *  as well as element alignment within the cells.
+ *
+ *  <p>Per-element supported constraints are 
+ *  <code>percentWidth</code> and <code>percentHeight</code>.
+ *  Element's minimum and maximum sizes are always be respected and
+ *  where possible, an element's size is limited to less then or equal
+ *  of the cell size.</p>
+ *
+ *  <p>When not explicitly set, the <code>columnWidth</code> property 
+ *  is calculated as the maximum preferred bounds width of all elements 
+ *  and the <code>columnHeight</code> property is calculated
+ *  as the maximum preferred bounds height of all elements.</p>
+ *
+ *  <p>When not explicitly set, the <code>columnCount</code> and 
+ *  <code>rowCount</code> properties are calculated from
+ *  any explicit width and height settings for the layout target, 
+ *  and <code>columnWidth</code> and <code>columnHeight</code>.  
+ *  In case none is specified, the <code>columnCount</code> and <code>rowCount</code>
+ *  values are picked so that the resulting pixel area is as square as possible.</p>
+ * 
+ * <p> The measured size is calculated from the <code>columnCount</code>, <code>rowCount</code>, 
+ *  <code>columnWidth</code>, <code>rowHeight</code> properties and the gap sizes.</p>
+ *
+ *  <p>The default measured size, when no properties were explicitly set, is
+ *  as square as possible area and is large enough to fit all elements.</p>
+ *
+ *  <p>In other cases the measured size may not be big enough to fit all elements.
+ *  For example, when both <code>columnCount</code> and <code>rowCount</code> are explicitly set to values
+ *  such that <code>columnCount</code> &#42; <code>rowCount</code> &lt; element count.</p>
+ *
+ *  <p>The minimum measured size is calculated the same way as the measured size but
+ *  it's guaranteed to encompass enough rows and columns along the minor axis to fit
+ *  all elements.</p>
+ *
+ *  @mxml 
+ *  <p>The <code>&lt;s:TileLayout&gt;</code> tag inherits all of the tag 
+ *  attributes of its superclass and adds the following tag attributes:</p>
+ *
+ *  <pre>
+ *  &lt;s:TileLayout 
+ *    <strong>Properties</strong>
+ *    columnAlign="left"
+ *    columnWidth="NaN"
+ *    horizontalAlign="justify"
+ *    horizontalGap="6"
+ *    orientation="rows"
+ *    requestedColumnCount="-1"
+ *    requestedRowCount="-1"
+ *    rowAlign="top"
+ *    rowCount="-1"
+ *    rowHeight="NaN"
+ *    verticalAlign="justify"
+ *    verticalGap="6"
+ *    padding="0"
+ *  /&gt;
+ *  </pre>
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+public class TileLayout extends LayoutBase
+{
+//    include "../core/Version.as";
+
+    //--------------------------------------------------------------------------
+    //
+    //  Constructor
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Constructor.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function TileLayout():void
+    {
+        super();
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Properties
+    //
+    //--------------------------------------------------------------------------
+
+    //----------------------------------
+    //  horizontalGap
+    //----------------------------------
+
+    private var explicitHorizontalGap:Number = 6;
+    private var _horizontalGap:Number = 6;
+
+    [Bindable("propertyChange")]
+    [Inspectable(category="General")]
+
+    /**
+     *  Horizontal space between columns, in pixels.
+     *
+     *  @see #verticalGap
+     *  @see #columnAlign
+     *  @default 6
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get horizontalGap():Number
+    {
+        return _horizontalGap;
+    }
+
+    /**
+     *  @private
+     */
+    public function set horizontalGap(value:Number):void
+    {
+        explicitHorizontalGap = value;
+        if (value == _horizontalGap)
+            return;
+
+        _horizontalGap = value;
+        invalidateTargetSizeAndDisplayList();
+    }
+
+    //----------------------------------
+    //  verticalGap
+    //----------------------------------
+
+    private var explicitVerticalGap:Number = 6;
+    private var _verticalGap:Number = 6;
+
+    [Bindable("propertyChange")]
+    [Inspectable(category="General")]
+
+    /**
+     *  Vertical space between rows, in pixels.
+     *
+     *  @see #horizontalGap
+     *  @see #rowAlign
+     *  @default 6
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get verticalGap():Number
+    {
+        return _verticalGap;
+    }
+
+    /**
+     *  @private
+     */
+    public function set verticalGap(value:Number):void
+    {
+        explicitVerticalGap = value;
+        if (value == _verticalGap)
+            return;
+
+        _verticalGap = value;
+        invalidateTargetSizeAndDisplayList();
+    }
+
+    //----------------------------------
+    //  columnCount
+    //----------------------------------
+
+    private var _columnCount:int = -1;
+
+    [Bindable("propertyChange")]
+    [Inspectable(category="General")]
+
+    /**
+     *  Contain the actual column count.
+     *
+     *  @see #rowCount
+     *  @see #columnAlign
+     *  @default -1
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get columnCount():int
+    {
+        return _columnCount;
+    }
+
+    //----------------------------------
+    //  requestedColumnCount
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the requestedColumnCount property.
+     */
+    private var _requestedColumnCount:int = -1;
+    
+    [Inspectable(category="General", minValue="-1")]
+
+    /**
+     *  Number of columns to be displayed.
+     * 
+     *  <p>Set to -1 to allow the TileLayout to determine
+     *  the column count automatically.</p>
+     *
+     *  <p>If the <code>orientation</code> property is set to <code>TileOrientation.ROWS</code>, 
+     *  then setting this property has no effect
+     *  In this case, the <code>rowCount</code> is explicitly set, and the
+     *  container width is explicitly set. </p>
+     * 
+     *  @see #columnCount
+     *  @see #columnAlign
+     *  @default -1
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get requestedColumnCount():int
+    {
+        return _requestedColumnCount;
+    }
+
+    /**
+     *  @private
+     */
+    public function set requestedColumnCount(value:int):void
+    {
+        if (_requestedColumnCount == value)
+            return;
+                               
+        _requestedColumnCount = value;
+        _columnCount = value;
+        invalidateTargetSizeAndDisplayList();
+    }    
+
+    //----------------------------------
+    //  rowCount
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the rowCount property.
+     */
+    private var _rowCount:int = -1;
+
+    [Bindable("propertyChange")]
+    [Inspectable(category="General")]
+
+    /**
+     *  The row count.
+     *
+     *  @see #requestedRowCount
+     *  @see #columnCount
+     *  @default -1
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get rowCount():int
+    {
+        return _rowCount;
+    }
+
+    //----------------------------------
+    //  requestedRowCount
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the requestedRowCount property.
+     */
+    private var _requestedRowCount:int = -1;
+    
+    [Inspectable(category="General", minValue="-1")]
+
+    /**
+     *  Number of rows to be displayed.
+     * 
+     *  <p>Set to -1 to remove explicit override and allow the TileLayout to determine
+     *  the row count automatically.</p>
+     *
+     *  <p>If the <code>orientation</code> property is set to 
+     *  <code>TileOrientation.COLUMNS</code>, setting this property has no effect.
+     *  in this case, <code>columnCount</code> is explicitly set, and the
+     *  container height is explicitly set.</p>
+     * 
+     *  @see #rowCount
+     *  @see #rowAlign
+     *  @default -1
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get requestedRowCount():int
+    {
+        return _requestedRowCount;
+    }
+
+    /**
+     *  @private
+     */
+    public function set requestedRowCount(value:int):void
+    {
+        if (_requestedRowCount == value)
+            return;
+                               
+        _requestedRowCount = value;
+        _rowCount = value;
+        invalidateTargetSizeAndDisplayList();
+    }    
+
+    //----------------------------------
+    //  columnWidth
+    //----------------------------------
+
+    private var explicitColumnWidth:Number = NaN;
+    private var _columnWidth:Number = NaN;
+
+    [Bindable("propertyChange")]
+    [Inspectable(category="General", minValue="0.0")]
+
+    /**
+     *  Contain the actual column width, in pixels.
+     *
+     *  <p>If not explicitly set, the column width is 
+     *  determined from the width of the widest element. </p>
+     *
+     *  <p>If the <code>columnAlign</code> property is set 
+     *  to <code>"justifyUsingWidth"</code>,  the column width grows to the 
+     *  container width to justify the fully-visible columns.</p>
+     *
+     *  @see #rowHeight
+     *  @see #columnAlign
+     *  @default NaN
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get columnWidth():Number
+    {
+        return _columnWidth;
+    }
+
+    /**
+     *  @private
+     */
+    public function set columnWidth(value:Number):void
+    {
+        explicitColumnWidth = value;
+        if (value == _columnWidth)
+            return;
+
+        _columnWidth = value;
+        invalidateTargetSizeAndDisplayList();
+    }
+
+    //----------------------------------
+    //  rowHeight
+    //----------------------------------
+
+    private var explicitRowHeight:Number = NaN;
+    private var _rowHeight:Number = NaN;
+
+    [Bindable("propertyChange")]
+    [Inspectable(category="General", minValue="0.0")]
+
+    /**
+     *  The row height, in pixels.
+     *
+     *  <p>If not explicitly set, the row height is 
+     *  determined from the maximum of elements' height.</p>
+     *
+     *  If <code>rowAlign</code> is set to "justifyUsingHeight", the actual row height
+     *  increases to justify the fully-visible rows to the container height.
+     *
+     *  @see #columnWidth
+     *  @see #rowAlign
+     *  @default NaN
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get rowHeight():Number
+    {
+        return _rowHeight;
+    }
+
+    /**
+     *  @private
+     */
+    public function set rowHeight(value:Number):void
+    {
+        explicitRowHeight = value;
+        if (value == _rowHeight)
+            return;
+
+        _rowHeight = value;
+        invalidateTargetSizeAndDisplayList();
+    }
+	
+	//----------------------------------
+	//  padding
+	//----------------------------------
+	
+	private var _padding:Number = 0;
+	
+	[Inspectable(category="General")]
+	
+	/**
+	 *  The minimum number of pixels between the container's edges and
+	 *  the edges of the layout element.
+	 * 
+	 *  @default 0
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10
+	 *  @playerversion AIR 1.5
+	 *  @productversion Flex 4
+	 */
+	public function get padding():Number
+	{
+		return _padding;
+	}
+	
+	/**
+	 *  @private
+	 */
+	public function set padding(value:Number):void
+	{
+		if (_padding == value)
+			return;
+		
+		_padding = value;
+		
+		paddingBottom = _padding;
+		paddingLeft = _padding;
+		paddingRight = _padding;
+		paddingTop = _padding;
+		
+		invalidateTargetSizeAndDisplayList();
+	}    
+    
+    //----------------------------------
+    //  paddingLeft
+    //----------------------------------
+    
+    private var _paddingLeft:Number = 0;
+    
+    [Inspectable(category="General")]
+    
+    /**
+     *  The minimum number of pixels between the container's left edge and
+     *  the left edge of the layout element.
+     * 
+     *  @default 0
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get paddingLeft():Number
+    {
+        return _paddingLeft;
+    }
+    
+    /**
+     *  @private
+     */
+    public function set paddingLeft(value:Number):void
+    {
+        if (_paddingLeft == value)
+            return;
+        
+        _paddingLeft = value;
+        invalidateTargetSizeAndDisplayList();
+    }    
+    
+    //----------------------------------
+    //  paddingRight
+    //----------------------------------
+    
+    private var _paddingRight:Number = 0;
+    
+    [Inspectable(category="General")]
+    
+    /**
+     *  The minimum number of pixels between the container's right edge and
+     *  the right edge of the layout element.
+     * 
+     *  @default 0
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get paddingRight():Number
+    {
+        return _paddingRight;
+    }
+    
+    /**
+     *  @private
+     */
+    public function set paddingRight(value:Number):void
+    {
+        if (_paddingRight == value)
+            return;
+        
+        _paddingRight = value;
+        invalidateTargetSizeAndDisplayList();
+    }    
+    
+    //----------------------------------
+    //  paddingTop
+    //----------------------------------
+    
+    private var _paddingTop:Number = 0;
+    
+    [Inspectable(category="General")]
+    
+    /**
+     *  Number of pixels between the container's top edge
+     *  and the top edge of the first layout element.
+     * 
+     *  @default 0
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get paddingTop():Number
+    {
+        return _paddingTop;
+    }
+    
+    /**
+     *  @private
+     */
+    public function set paddingTop(value:Number):void
+    {
+        if (_paddingTop == value)
+            return;
+        
+        _paddingTop = value;
+        invalidateTargetSizeAndDisplayList();
+    }    
+    
+    //----------------------------------
+    //  paddingBottom
+    //----------------------------------
+    
+    private var _paddingBottom:Number = 0;
+    
+    [Inspectable(category="General")]
+    
+    /**
+     *  Number of pixels between the container's bottom edge
+     *  and the bottom edge of the last layout element.
+     * 
+     *  @default 0
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get paddingBottom():Number
+    {
+        return _paddingBottom;
+    }
+    
+    /**
+     *  @private
+     */
+    public function set paddingBottom(value:Number):void
+    {
+        if (_paddingBottom == value)
+            return;
+        
+        _paddingBottom = value;
+        invalidateTargetSizeAndDisplayList();
+    }
+    
+    //----------------------------------
+    //  horizontalAlign
+    //----------------------------------
+
+    private var _horizontalAlign:String = HorizontalAlign.JUSTIFY;
+
+    [Inspectable(category="General", enumeration="left,right,center,justify", defaultValue="justify")]
+
+    /**
+     *  Specifies how to align the elements within the cells in the horizontal direction.
+     *  Supported values are
+     *  <code>HorizontalAlign.LEFT</code>,
+     *  <code>HorizontalAlign.CENTER</code>,
+     *  <code>HorizontalAlign.RIGHT</code>,
+     *  <code>HorizontalAlign.JUSTIFY</code>.
+     *
+     *  <p>When set to <code>HorizontalAlign.JUSTIFY</code> the width of each
+     *  element is set to the <code>columnWidth</code>.</p>
+     *
+     *  @default <code>HorizontalAlign.JUSTIFY</code>
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get horizontalAlign():String
+    {
+        return _horizontalAlign;
+    }
+
+    /**
+     *  @private
+     */
+    public function set horizontalAlign(value:String):void
+    {
+        if (_horizontalAlign == value)
+            return;
+
+        _horizontalAlign = value;
+        invalidateTargetSizeAndDisplayList();
+    }
+
+    //----------------------------------
+    //  verticalAlign
+    //----------------------------------
+
+    private var _verticalAlign:String = VerticalAlign.JUSTIFY;
+
+    [Inspectable(category="General", enumeration="top,bottom,middle,justify", defaultValue="justify")]
+
+    /**
+     *  Specifies how to align the elements within the cells in the vertical direction.
+     *  Supported values are
+     *  <code>VerticalAlign.TOP</code>,
+     *  <code>VerticalAlign.MIDDLE</code>,
+     *  <code>VerticalAlign.BOTTOM</code>,
+     *  <code>VerticalAlign.JUSTIFY</code>.
+     *
+     *  <p>When set to <code>VerticalAlign.JUSTIFY</code>, the height of each
+     *  element is set to <code>rowHeight</code>.</p>
+     *
+     *  @default <code>VerticalAlign.JUSTIFY</code>
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get verticalAlign():String
+    {
+        return _verticalAlign;
+    }
+
+    /**
+     *  @private
+     */
+    public function set verticalAlign(value:String):void
+    {
+        if (_verticalAlign == value)
+            return;
+
+        _verticalAlign = value;
+        invalidateTargetSizeAndDisplayList();
+    }
+
+    //----------------------------------
+    //  columnAlign
+    //----------------------------------
+
+    private var _columnAlign:String = ColumnAlign.LEFT;
+
+    [Inspectable(category="General", enumeration="left,justifyUsingGap,justifyUsingWidth", defaultValue="left")]
+
+    /**
+     *  Specifies how to justify the fully visible columns to the container width.
+     *  ActionScript values can be <code>ColumnAlign.LEFT</code>, <code>ColumnAlign.JUSTIFY_USING_GAP</code>
+     *  and <code>ColumnAlign.JUSTIFY_USING_WIDTH</code>.
+     *  MXML values can be <code>"left"</code>, <code>"justifyUsingGap"</code> and <code>"justifyUsingWidth"</code>.
+     *
+     *  <p>When set to <code>ColumnAlign.LEFT</code> it turns column justification off.
+     *  There may be partially visible columns or whitespace between the last column and
+     *  the right edge of the container.  This is the default value.</p>
+     *
+     *  <p>When set to <code>ColumnAlign.JUSTIFY_USING_GAP</code> the <code>horizontalGap</code>
+     *  actual value increases so that
+     *  the last fully visible column right edge aligns with the container's right edge.
+     *  In case there is only a single fully visible column, the <code>horizontalGap</code> actual value
+     *  increases so that it pushes any partially visible column beyond the right edge
+     *  of the container.  
+     *  Note that explicitly setting the <code>horizontalGap</code> property does not turn off
+     *  justification. It only determines the initial gap value. 
+     *  Justification may increases it.</p>
+     *
+     *  <p>When set to <code>ColumnAlign.JUSTIFY_USING_WIDTH</code> the <code>columnWidth</code>
+     *  actual value increases so that
+     *  the last fully visible column right edge aligns with the container's right edge.  
+     *  Note that explicitly setting the <code>columnWidth</code> property does not turn off justification.
+     *  It only determines the initial column width value. 
+     *  Justification may increases it.</p>
+     *
+     *  @see #horizontalGap
+     *  @see #columnWidth
+     *  @see #rowAlign
+     *  @default ColumnAlign.LEFT
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get columnAlign():String
+    {
+        return _columnAlign;
+    }
+
+    /**
+     *  @private
+     */
+    public function set columnAlign(value:String):void
+    {
+        if (_columnAlign == value)
+            return;
+
+        _columnAlign = value;
+        invalidateTargetSizeAndDisplayList();
+    }
+
+    //----------------------------------
+    //  rowAlign
+    //----------------------------------
+
+    private var _rowAlign:String = RowAlign.TOP;
+
+    [Inspectable(category="General", enumeration="top,justifyUsingGap,justifyUsingHeight", defaultValue="top")]
+
+    /**
+     *  Specifies how to justify the fully visible rows to the container height.
+     *  ActionScript values can be <code>RowAlign.TOP</code>, <code>RowAlign.JUSTIFY_USING_GAP</code>
+     *  and <code>RowAlign.JUSTIFY_USING_HEIGHT</code>.
+     *  MXML values can be <code>"top"</code>, <code>"justifyUsingGap"</code> and <code>"justifyUsingHeight"</code>.
+     *
+     *  <p>When set to <code>RowAlign.TOP</code> it turns column justification off. 
+     *  There might be partially visible rows or whitespace between the last row and
+     *  the bottom edge of the container.  This is the default value.</p>
+     *
+     *  <p>When set to <code>RowAlign.JUSTIFY_USING_GAP</code> the <code>verticalGap</code>
+     *  actual value increases so that
+     *  the last fully visible row bottom edge aligns with the container's bottom edge.
+     *  In case there is only a single fully visible row, the value of <code>verticalGap</code> 
+     *  increases so that it pushes any partially visible row beyond the bottom edge
+     *  of the container.  Note that explicitly setting the <code>verticalGap</code> does not turn off
+     *  justification, but just determines the initial gap value.
+     *  Justification can then increases it.</p>
+     *
+     *  <p>When set to <code>RowAlign.JUSTIFY_USING_HEIGHT</code> the <code>rowHeight</code>
+     *  actual value increases so that
+     *  the last fully visible row bottom edge aligns with the container's bottom edge.  Note that
+     *  explicitly setting the <code>rowHeight</code> does not turn off justification, but 
+     *  determines the initial row height value.
+     *  Justification can then increase it.</p>
+     *
+     *  @see #verticalGap
+     *  @see #rowHeight
+     *  @see #columnAlign
+     *  @default RowAlign.TOP
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get rowAlign():String
+    {
+        return _rowAlign;
+    }
+
+    /**
+     *  @private
+     */
+    public function set rowAlign(value:String):void
+    {
+        if (_rowAlign == value)
+            return;
+
+        _rowAlign = value;
+        invalidateTargetSizeAndDisplayList();
+    }
+
+    //----------------------------------
+    //  orientation
+    //----------------------------------
+
+    private var _orientation:String = TileOrientation.ROWS;
+
+    [Inspectable(category="General", enumeration="rows,columns", defaultValue="rows")]
+
+    /**
+     *  Specifies whether elements are arranged row by row or
+     *  column by column.
+     *  ActionScript values can be <code>TileOrientation.ROWS</code> and 
+     *  <code>TileOrientation.COLUMNS</code>.
+     *  MXML values can be <code>"rows"</code> and <code>"columns"</code>.
+     *
+     *  @default TileOrientation.ROWS
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get orientation():String
+    {
+        return _orientation;
+    }
+
+    /**
+     *  @private
+     */
+    public function set orientation(value:String):void
+    {
+        if (_orientation == value)
+            return;
+
+        _orientation = value;
+        _tileWidthCached = _tileHeightCached = NaN;
+        invalidateTargetSizeAndDisplayList();
+    }
+    
+    //----------------------------------
+    //  useVirtualLayout
+    //----------------------------------
+    
+    /**
+     *  @private
+     */
+    override public function set useVirtualLayout(value:Boolean):void
+    {
+        if (useVirtualLayout == value)
+            return;
+            
+        super.useVirtualLayout = value;
+        
+        // Reset the state that virtual depends on.  If the layout has already
+        // run with useVirtualLayout=false, the visibleStartEndIndex variables
+        // will have been set to 0, dataProvider.length.
+        if (value)
+        {
+            visibleStartIndex = -1;  
+            visibleEndIndex = -1;    
+            visibleStartX = 0;
+            visibleStartY = 0;
+        }
+    }     
+    
+    //--------------------------------------------------------------------------
+    //
+    //  Variables
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     * @private
+     */
+    override public function clearVirtualLayoutCache():void
+    {
+        _tileWidthCached = _tileHeightCached = NaN;
+    }
+    
+    /**
+     *  @private
+     *  storage for old property values, in order to dispatch change events.
+     */
+    private var oldColumnWidth:Number = NaN;
+    private var oldRowHeight:Number = NaN;
+    private var oldColumnCount:int = -1;
+    private var oldRowCount:int = -1;
+    private var oldHorizontalGap:Number = NaN;
+    private var oldVerticalGap:Number = NaN;
+
+    // Cache storage to avoid repeating work from measure() in updateDisplayList().
+    // These are set the first time the value is calculated and are reset at the end
+    // of updateDisplayList().
+    private var _tileWidthCached:Number = NaN;
+    private var _tileHeightCached:Number = NaN;
+    private var _numElementsCached:int = -1;
+    
+    /**
+     *  @private
+     *  The following variables are used by updateDisplayList() and set by
+     *  calculateDisplayParameters().   If virtualLayout=true they're based 
+     *  on the current scrollRect.
+     */
+    private var visibleStartIndex:int = -1;   // dataProvider/layout element index  
+    private var visibleEndIndex:int = -1;     // ...
+    private var visibleStartX:Number = 0;     // first tile/cell origin
+    private var visibleStartY:Number = 0;     // ...
+   
+    //--------------------------------------------------------------------------
+    //
+    //  Class methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Dispatches events if Actual values have changed since the last call.
+     *  Checks columnWidth, rowHeight, columnCount, rowCount, horizontalGap, verticalGap.
+     *  This method is called from within updateDisplayList()
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    private function dispatchEventsForActualValueChanges():void
+    {
+        if (hasEventListener(PropertyChangeEvent.PROPERTY_CHANGE))
+        {
+            if (oldColumnWidth != _columnWidth)
+                dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "columnWidth", oldColumnWidth, _columnWidth));
+            if (oldRowHeight != _rowHeight)
+                dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "rowHeight", oldRowHeight, _rowHeight));
+            if (oldColumnCount != _columnCount)
+                dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "columnCount", oldColumnCount, _columnCount));
+            if (oldRowCount != _rowCount)
+                dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "rowCount", oldRowCount, _rowCount));
+            if (oldHorizontalGap != _horizontalGap)
+                dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "horizontalGap", oldHorizontalGap, _horizontalGap));
+            if (oldVerticalGap != _verticalGap)
+                dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "verticalGap", oldVerticalGap, _verticalGap));
+        }
+
+        oldColumnWidth   = _columnWidth;
+        oldRowHeight     = _rowHeight;
+        oldColumnCount   = _columnCount;
+        oldRowCount      = _rowCount;
+        oldHorizontalGap = _horizontalGap;
+        oldVerticalGap   = _verticalGap;
+    }
+
+    /**
+     *  This method is called from measure() and updateDisplayList() to calculate the
+     *  actual values for columnWidth, rowHeight, columnCount, rowCount, horizontalGap and verticalGap.
+     *  The width and height should include padding because the padding is accounted for in
+     *  the calculations.
+     *
+     *  @param width - the width during measure() is the layout target explicitWidth or NaN
+     *  and during updateDisplayList() is the unscaledWidth.
+     *  @param height - the height during measure() is the layout target explicitHeight or NaN
+     *  and during updateDisplayList() is the unscaledHeight.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    private function updateActualValues(width:Number, height:Number):void
+    {
+        var widthMinusPadding:Number = width - paddingLeft - paddingRight;
+        var heightMinusPadding:Number = height - paddingTop - paddingBottom;
+        
+        // First, figure the tile size
+        calculateTileSize();
+
+        // Second, figure out number of rows/columns
+        var elementCount:int = calculateElementCount();
+        calculateColumnAndRowCount(widthMinusPadding, heightMinusPadding, elementCount);
+
+        // Third, adjust the gaps and column and row sizes based on justification settings
+        _horizontalGap = explicitHorizontalGap;
+        _verticalGap = explicitVerticalGap;
+
+        // Justify
+		if (!isNaN(width))
+		{
+            switch (columnAlign)
+            {
+                case ColumnAlign.JUSTIFY_USING_GAP:
+                    _horizontalGap = justifyByGapSize(widthMinusPadding, _columnWidth, _horizontalGap, _columnCount);
+                    break;
+                case ColumnAlign.JUSTIFY_USING_WIDTH:
+                    _columnWidth = justifyByElementSize(widthMinusPadding, _columnWidth, _horizontalGap, _columnCount);
+                    break;
+	        }
+		}
+
+		if (!isNaN(height))
+		{
+            switch (rowAlign)
+            {
+                case RowAlign.JUSTIFY_USING_GAP:
+                    _verticalGap = justifyByGapSize(heightMinusPadding, _rowHeight, _verticalGap, _rowCount);
+                    break;
+                case RowAlign.JUSTIFY_USING_HEIGHT:
+                    _rowHeight = justifyByElementSize(heightMinusPadding, _rowHeight, _verticalGap, _rowCount);
+                    break;
+	        }
+		}
+
+        // Last, if we have explicit overrides for both rowCount and columnCount, then
+        // make sure that column/row count along the minor axis reflects the actual count.
+        if (-1 != _requestedColumnCount && -1 != _requestedRowCount)
+        {
+            if (orientation == TileOrientation.ROWS)
+                _rowCount = Math.max(1, Math.ceil(elementCount / Math.max(1, _requestedColumnCount)));
+            else
+                _columnCount = Math.max(1, Math.ceil(elementCount / Math.max(1, _requestedRowCount)));
+        }
+    }
+    
+    /**
+     *  @private
+     *  Returns true, if the dimensions (colCount1, rowCount1) are more square than (colCount2, rowCount2).
+     *  Squareness is the difference between width and height of a tile layout
+     *  with the specified number of columns and rows.
+     */
+    private function closerToSquare(colCount1:int, rowCount1:int, colCount2:int, rowCount2:int):Boolean
+    {
+        var difference1:Number = Math.abs(colCount1 * (_columnWidth + _horizontalGap) - _horizontalGap - 
+                                          rowCount1 * (_rowHeight   +   _verticalGap) + _verticalGap);
+        var difference2:Number = Math.abs(colCount2 * (_columnWidth + _horizontalGap) - _horizontalGap - 
+                                          rowCount2 * (_rowHeight   +   _verticalGap) + _verticalGap);
+        
+        return difference1 < difference2 || (difference1 == difference2 && rowCount1 <= rowCount2);
+    }
+
+    /**
+     *  @private
+     *  Calculates _columnCount and _rowCount based on width, height,
+     *  orientation, _requestedColumnCount, _requestedRowCount, _columnWidth, _rowHeight.
+     *  _columnWidth and _rowHeight must be valid before calling.
+     * 
+     *  The width and height should not include padding.
+     */
+    private function calculateColumnAndRowCount(width:Number, height:Number, elementCount:int):void
+    {
+        _columnCount = _rowCount = -1;
+
+        if (-1 != _requestedColumnCount || -1 != _requestedRowCount)
+        {
+            if (-1 != _requestedRowCount)
+                _rowCount = Math.max(1, _requestedRowCount);
+
+            if (-1 != _requestedColumnCount)
+                _columnCount = Math.max(1, _requestedColumnCount);
+        }
+        // Figure out number of columns or rows based on the explicit size along one of the axes
+        else if (!isNaN(width) && (orientation == TileOrientation.ROWS || isNaN(height)))
+        {
+            if (_columnWidth + explicitHorizontalGap > 0)
+                _columnCount = Math.max(1, Math.floor((width + explicitHorizontalGap) / (_columnWidth + explicitHorizontalGap)));
+            else
+                _columnCount = 1;
+        }
+        else if (!isNaN(height) && (orientation == TileOrientation.COLUMNS || isNaN(width)))
+        {
+            if (_rowHeight + explicitVerticalGap > 0)
+                _rowCount = Math.max(1, Math.floor((height + explicitVerticalGap) / (_rowHeight + explicitVerticalGap)));
+            else
+                _rowCount = 1;
+        }
+        else // Figure out the number of columns and rows so that pixels area occupied is as square as possible
+        {
+            // Calculate number of rows and columns so that
+            // pixel area is as square as possible
+            var hGap:Number = explicitHorizontalGap;
+            var vGap:Number = explicitVerticalGap;
+
+            // 1. columnCount * (columnWidth + hGap) - hGap == rowCount * (rowHeight + vGap) - vGap
+            // 1. columnCount * (columnWidth + hGap) == rowCount * (rowHeight + vGap) + hGap - vGap
+            // 1. columnCount == (rowCount * (rowHeight + vGap) + hGap - vGap) / (columnWidth + hGap)
+            // 2. columnCount * rowCount == elementCount
+            // substitute 1. in 2.
+            // rowCount * rowCount + (hGap - vGap) * rowCount - elementCount * (columnWidth + hGap ) == 0
+
+            var a:Number = Math.max(0, (rowHeight + vGap));
+            var b:Number = (hGap - vGap);
+            var c:Number = -elementCount * (_columnWidth + hGap);
+            var d:Number = b * b - 4 * a * c; // Always guaranteed to be greater than zero, since c <= 0
+            d = Math.sqrt(d);
+
+            // We are guaranteed that we have only one positive root, since d >= b:
+            var rowCount:Number = (a != 0) ? (b + d) / (2 * a) : elementCount;
+
+            // To get integer count for the columns/rows we round up and down so
+            // we get four possible solutions. Then we pick the best one.
+            var row1:int = Math.max(1, Math.floor(rowCount));
+            var col1:int = Math.max(1, Math.ceil(elementCount / row1));
+            row1 = Math.max(1, Math.ceil(elementCount / col1));
+
+            var row2:int = Math.max(1, Math.ceil(rowCount));
+            var col2:int = Math.max(1, Math.ceil(elementCount / row2));
+            row2 = Math.max(1, Math.ceil(elementCount / col2));
+
+            var col3:int = Math.max(1, Math.floor(elementCount / rowCount));
+            var row3:int = Math.max(1, Math.ceil(elementCount / col3));
+            col3 = Math.max(1, Math.ceil(elementCount / row3));
+
+            var col4:int = Math.max(1, Math.ceil(elementCount / rowCount));
+            var row4:int = Math.max(1, Math.ceil(elementCount / col4));
+            col4 = Math.max(1, Math.ceil(elementCount / row4));
+
+            if (closerToSquare(col3, row3, col1, row1))
+            {
+                col1 = col3;
+                row1 = row3;
+            }
+
+            if (closerToSquare(col4, row4, col2, row2))
+            {
+                col2 = col4;
+                row2 = row4;
+            }
+
+            if (closerToSquare(col1, row1, col2, row2))
+            {
+                _columnCount = col1;
+                _rowCount = row1;
+            }
+            else
+            {
+                _columnCount = col2;
+                _rowCount = row2;
+            }
+        }
+
+        // In case we determined only columns or rows (from explicit overrides or explicit width/height)
+        // calculate the other from the number of elements
+        if (-1 == _rowCount)
+            _rowCount = Math.max(1, Math.ceil(elementCount / _columnCount));
+        if (-1 == _columnCount)
+            _columnCount = Math.max(1, Math.ceil(elementCount / _rowCount));
+    }
+
+    /**
+     *  @private
+     *  Increases the gap so that elements are justified to exactly fit totalSize
+     *  leaving no partially visible elements in view.
+     *  @return Returs the new gap size.
+     */
+    private function justifyByGapSize(totalSize:Number, elementSize:Number,
+                                      gap:Number, elementCount:int):Number
+    {
+        // If element + gap collapses to zero, then don't adjust the gap.
+        if (elementSize + gap <= 0)
+            return gap;
+
+        // Find the number of fully visible elements
+        var visibleCount:int =
+            Math.min(elementCount, Math.floor((totalSize + gap) / (elementSize + gap)));
+
+        // If there isn't even a singel fully visible element, don't adjust the gap
+        if (visibleCount < 1)
+            return gap;
+
+        // Special case: if there's a singe fully visible element and a partially
+        // visible element, then make the gap big enough to push out the partially
+        // visible element out of view.
+        if (visibleCount == 1)
+            return elementCount > 1 ? Math.max(gap, totalSize - elementSize) : gap;
+
+        // Now calculate the gap such that the fully visible elements and gaps
+        // add up exactly to totalSize:
+        // <==> totalSize == visibleCount * elementSize + (visibleCount - 1) * gap
+        // <==> totalSize - visibleCount * elementSize == (visibleCount - 1) * gap
+        // <==> (totalSize - visibleCount * elementSize) / (visibleCount - 1) == gap
+        return (totalSize - visibleCount * elementSize) / (visibleCount - 1);
+    }
+
+    /**
+     *  @private
+     *  Increases the element size so that elements are justified to exactly fit
+     *  totalSize leaving no partially visible elements in view.
+     *  @return Returns the the new element size.
+     */
+    private function justifyByElementSize(totalSize:Number, elementSize:Number,
+                                          gap:Number, elementCount:int):Number
+    {
+        var elementAndGapSize:Number = elementSize + gap;
+        var visibleCount:int = 0;
+        // Find the number of fully visible elements
+        if (elementAndGapSize == 0)
+            visibleCount = elementCount;
+        else
+            visibleCount = Math.min(elementCount, Math.floor((totalSize + gap) / elementAndGapSize));
+
+        // If there isn't event a single fully visible element, don't adjust
+        if (visibleCount < 1)
+            return elementSize;
+
+        // Now calculate the elementSize such that the fully visible elements and gaps
+        // add up exactly to totalSize:
+        // <==> totalSize == visibleCount * elementSize + (visibleCount - 1) * gap
+        // <==> totalSize - (visibleCount - 1) * gap == visibleCount * elementSize
+        // <==> (totalSize - (visibleCount - 1) * gap) / visibleCount == elementSize
+        return (totalSize - (visibleCount - 1) * gap) / visibleCount;
+    }
+
+    /**
+     *  @private
+     *  Update _tileWidth,Height to be the maximum of their current
+     *  value and the element's preferred bounds. 
+     */
+    private function updateVirtualTileSize(elt:ILayoutElement):void
+    {
+        if (!elt || !elt.includeInLayout)
+            return;
+        var w:Number = elt.getPreferredBoundsWidth();
+        var h:Number = elt.getPreferredBoundsHeight();
+        _tileWidthCached = isNaN(_tileWidthCached) ? w : Math.max(w, _tileWidthCached);
+        _tileHeightCached = isNaN(_tileHeightCached) ? h : Math.max(h, _tileHeightCached);
+    }
+    
+    /**
+     *  @private
+     */
+    private function calculateVirtualTileSize():void
+    {
+        // If both dimensions are explicitly set, we're done
+        _columnWidth = explicitColumnWidth;
+        _rowHeight = explicitRowHeight;
+        if (!isNaN(_columnWidth) && !isNaN(_rowHeight))
+        {
+            _tileWidthCached = _columnWidth;
+            _tileHeightCached = _rowHeight;
+            return;
+        }
+        
+        // update _tileWidth,HeightCached based on the typicalElement     
+        updateVirtualTileSize(typicalLayoutElement);
+        
+        // update _tileWidth,HeightCached based on visible elements    
+        if ((visibleStartIndex != -1) && (visibleEndIndex != -1))
+        {
+            for (var index:int = visibleStartIndex; index <= visibleEndIndex; index++)
+                updateVirtualTileSize(target.getVirtualElementAt(index));
+        }
+        
+        // Make sure that we always have non-NaN values in the cache, even
+        // when there are no elements.
+        if (isNaN(_tileWidthCached))
+            _tileWidthCached = 0;
+        if (isNaN(_tileHeightCached))
+            _tileHeightCached = 0;
+        
+        if (isNaN(_columnWidth))
+            _columnWidth = _tileWidthCached;
+        if (isNaN(_rowHeight))
+            _rowHeight = _tileHeightCached;        
+    }
+
+    /**
+     *  @private
+     *  Calculates _columnWidth and _rowHeight from maximum of
+     *  elements preferred size and any explicit overrides.
+     */
+    private function calculateRealTileSize():void
+    {
+        _columnWidth = _tileWidthCached;
+        _rowHeight = _tileHeightCached;
+        if (!isNaN(_columnWidth) && !isNaN(_rowHeight))
+            return;
+
+        // Are both dimensions explicitly set?
+        _columnWidth = _tileWidthCached = explicitColumnWidth;
+        _rowHeight = _tileHeightCached = explicitRowHeight;
+        if (!isNaN(_columnWidth) && !isNaN(_rowHeight))
+            return;
+
+        // Find the maxmimums of element's preferred sizes
+        var columnWidth:Number = 0;
+        var rowHeight:Number = 0;
+
+        var layoutTarget:GroupBase = target;
+        var count:int = layoutTarget.numElements;
+        // Remember the number of includeInLayout elements
+        _numElementsCached = count;
+        for (var i:int = 0; i < count; i++)
+        {
+            var el:ILayoutElement = layoutTarget.getElementAt(i);
+            if (!el || !el.includeInLayout)
+            {
+                _numElementsCached--;
+                continue;
+            }
+
+            if (isNaN(_columnWidth))
+                columnWidth = Math.max(columnWidth, el.getPreferredBoundsWidth());
+            if (isNaN(_rowHeight))
+                rowHeight = Math.max(rowHeight, el.getPreferredBoundsHeight());
+        }
+
+        if (isNaN(_columnWidth))
+            _columnWidth = _tileWidthCached = columnWidth;
+        if (isNaN(_rowHeight))
+            _rowHeight = _tileHeightCached = rowHeight;
+    }
+    
+    private function calculateTileSize():void    
+    {
+        if (useVirtualLayout)
+            calculateVirtualTileSize();
+        else 
+            calculateRealTileSize();
+    }    
+
+    /**
+     *  @private
+     *  For normal layout return the number of non-null includeInLayout=true
+     *  layout elements, for virtual layout just return the number of layout
+     *  elements.
+     */
+    private function calculateElementCount():int
+    {
+        if (-1 != _numElementsCached)
+            return _numElementsCached;
+            
+        var layoutTarget:GroupBase = target;
+        var count:int = layoutTarget.numElements;
+        _numElementsCached = count;
+
+        if (useVirtualLayout)
+            return _numElementsCached;
+            
+        for (var i:int = 0; i < count; i++)
+        {
+            var el:ILayoutElement = layoutTarget.getElementAt(i);
+            if (!el || !el.includeInLayout)
+                _numElementsCached--;
+        }
+
+        return _numElementsCached;
+    }
+    
+    /**
+     *  @private
+     *  This method computes values for visibleStartX,Y, visibleStartIndex, and 
+     *  visibleEndIndex based on the TileLayout geometry values, like _columnWidth
+     *  and _rowHeight, computed by calculateActualValues().
+     * 
+     *  If useVirtualLayout=false, then visibleStartX,Y=0 and visibleStartIndex=0
+     *  and visibleEndIndex=layoutTarget.numElements-1.
+     * 
+     *  If useVirtualLayout=true and orientation=ROWS then visibleStartIndex is the 
+     *  layout element index of the item at first visible row relative to the scrollRect, 
+     *  column 0.  Note that we're using column=0 instead of the first visible column
+     *  to simplify the iteration logic in updateDisplayList().  This is optimal 
+     *  for the common case where the entire row is visible.   Optimally handling 
+     *  the case where orientation=ROWS and each row is only partially visible is 
+     *  doable but adds some complexity to the main loop.
+     * 
+     *  The logic for useVirtualLayout=true and orientation=COLS is similar.
+     */
+    private function calculateDisplayParameters(unscaledWidth:int, unscaledHeight:int):void
+    {
+        updateActualValues(unscaledWidth, unscaledHeight);
+
+        var layoutTarget:GroupBase = target;
+        var eltCount:int = layoutTarget.numElements;
+        visibleStartX = paddingLeft;   // initial values for xPos,yPos in updateDisplayList
+        visibleStartY = paddingTop;
+        visibleStartIndex = 0;
+        visibleEndIndex = eltCount - 1;
+
+        if (useVirtualLayout)
+        {
+            var hsp:Number = layoutTarget.horizontalScrollPosition - paddingLeft;
+            var vsp:Number = layoutTarget.verticalScrollPosition - paddingTop;
+            var cwg:Number = _columnWidth + _horizontalGap;
+            var rwg:Number = _rowHeight + _verticalGap;
+            
+            var visibleCol0:int = Math.max(0, Math.floor(hsp / cwg));
+            var visibleRow0:int = Math.max(0, Math.floor(vsp / rwg));
+            var visibleCol1:int = Math.min(_columnCount - 1, Math.floor((hsp + unscaledWidth) / cwg));
+            var visibleRow1:int = Math.min(_rowCount - 1, Math.floor((vsp + unscaledHeight) / rwg));
+
+            if (orientation == TileOrientation.ROWS)
+            {
+                visibleStartIndex = (visibleRow0 * _columnCount);
+                visibleEndIndex = Math.min(eltCount - 1, (visibleRow1 * _columnCount) + visibleCol1); 
+                visibleStartY = visibleRow0 * rwg + paddingTop;
+            }
+            else
+            {
+                visibleStartIndex = (visibleCol0 * _rowCount);
+                visibleEndIndex = Math.min(eltCount - 1, (visibleCol1 * _rowCount) + visibleRow1);
+                visibleStartX = visibleCol0 * cwg + paddingLeft;       
+            }
+        }
+    }
+    
+    /**
+     *  @private
+     *  This method is called by updateDisplayList() after initial values for 
+     *  visibleStartIndex, visibleEndIndex have been calculated.  We 
+     *  re-calculateDisplayParameters() to account for the possibility that
+     *  larger cells may have been exposed.  Since tileWidth,Height can only
+     *  increase, the new visibleStart,EndIndex values will be greater than or
+     *  equal to the old ones. 
+     */
+     private function updateVirtualLayout(unscaledWidth:int, unscaledHeight:int):void
+     {
+        var oldVisibleStartIndex:int = visibleStartIndex;
+        var oldVisibleEndIndex:int = visibleEndIndex;
+        calculateDisplayParameters(unscaledWidth, unscaledHeight);  // compute new visibleStart,EndIndex values
+        
+        // We're responsible for laying out *all* of the elements requested
+        // with getVirtualElementAt(), even if they don't fall within the final
+        // visible range.  Hide any extra ones.  On the next layout pass, they'll
+        // be added to DataGroup::freeRenderers
+        
+        var layoutTarget:GroupBase = target;
+        for (var i:int = oldVisibleStartIndex; i <= oldVisibleEndIndex; i++)
+        {
+            if ((i >= visibleStartIndex) && (i <= visibleEndIndex)) // skip past the visible range
+            {
+                i = visibleEndIndex;
+                continue;
+            } 
+            var el:ILayoutElement = layoutTarget.getElementAt(i);
+            if (!el)
+                continue;
+            if (el is IVisualElement)
+                IVisualElement(el).visible = false; 
+        }
+     }    
+
+    /**
+     *  Sets the size and the position of the specified layout element and cell bounds.
+     *  @param element - the element to resize and position.
+     *  @param cellX - the x coordinate of the cell.
+     *  @param cellY - the y coordinate of the cell.
+     *  @param cellWidth - the width of the cell.
+     *  @param cellHeight - the height of the cell.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    private function sizeAndPositionElement(element:ILayoutElement,
+                                              cellX:int,
+                                              cellY:int,
+                                              cellWidth:int,
+                                              cellHeight:int):void
+    {
+        var childWidth:Number = NaN;
+        var childHeight:Number = NaN;
+
+        // Determine size of the element
+        if (horizontalAlign == "justify")
+            childWidth = cellWidth;
+        else if (!isNaN(element.percentWidth))
+            childWidth = Math.round(cellWidth * element.percentWidth * 0.01);
+        else
+            childWidth = element.getPreferredBoundsWidth();
+
+        if (verticalAlign == "justify")
+            childHeight = cellHeight;
+        else if (!isNaN(element.percentHeight))
+            childHeight = Math.round(cellHeight * element.percentHeight * 0.01);
+        else
+            childHeight = element.getPreferredBoundsHeight();
+
+        // Enforce min and max limits
+        var maxChildWidth:Number = Math.min(element.getMaxBoundsWidth(), cellWidth);
+        var maxChildHeight:Number = Math.min(element.getMaxBoundsHeight(), cellHeight);
+        // Make sure we enforce element's minimum last, since it has the highest priority
+        childWidth = Math.max(element.getMinBoundsWidth(), Math.min(maxChildWidth, childWidth));
+        childHeight = Math.max(element.getMinBoundsHeight(), Math.min(maxChildHeight, childHeight));
+
+        // Size the element
+        element.setLayoutBoundsSize(childWidth, childHeight);
+
+        var x:Number = cellX;
+        switch (horizontalAlign)
+        {
+            case "right":
+                x += cellWidth - element.getLayoutBoundsWidth();
+            break;
+            case "center":
+                // Make sure division result is integer - Math.floor() the result.
+                x = cellX + Math.floor((cellWidth - element.getLayoutBoundsWidth()) / 2);
+            break;
+        }
+
+        var y:Number = cellY;
+        switch (verticalAlign)
+        {
+            case "bottom":
+                y += cellHeight - element.getLayoutBoundsHeight();
+            break;
+            case "middle":
+                // Make sure division result is integer - Math.floor() the result.
+                y += Math.floor((cellHeight - element.getLayoutBoundsHeight()) / 2);
+            break;
+        }
+
+        // Position the element
+        element.setLayoutBoundsPosition(x, y);
+    }
+
+    /**
+     *  @private
+     *  @return Returns the x coordinate of the left edge for the specified column.
+     */
+    final private function leftEdge(columnIndex:int):Number
+    {
+        if (columnIndex < 0)
+            return 0;
+        
+        return Math.max(0, columnIndex * (_columnWidth + _horizontalGap)) + paddingLeft;
+    }
+
+    /**
+     *  @private
+     *  @return Returns the x coordinate of the right edge for the specified column.
+     */
+    final private function rightEdge(columnIndex:int):Number
+    {
+        if (columnIndex < 0)
+            return 0;
+        
+        return Math.min(target.contentWidth, columnIndex * (_columnWidth + _horizontalGap) + _columnWidth) + paddingLeft;
+    }
+
+    /**
+     *  @private
+     *  @return Returns the y coordinate of the top edge for the specified row.
+     */
+    final private function topEdge(rowIndex:int):Number
+    {
+        if (rowIndex < 0)
+            return 0;
+        
+        return Math.max(0, rowIndex * (_rowHeight + _verticalGap)) + paddingTop;
+    }
+
+    /**
+     *  @private
+     *  @return Returns the y coordinate of the bottom edge for the specified row.
+     */
+    final private function bottomEdge(rowIndex:int):Number
+    {
+        if (rowIndex < 0)
+            return 0;
+        
+        return Math.min(target.contentHeight, rowIndex * (_rowHeight + _verticalGap) + _rowHeight) + paddingTop;
+    }
+    
+    /**
+     *  @private 
+     *  Convenience function for subclasses that invalidates the
+     *  target's size and displayList so that both layout's <code>measure()</code>
+     *  and <code>updateDisplayList</code> methods get called.
+     * 
+     *  <p>Typically a layout invalidates the target's size and display list so that
+     *  it gets a chance to recalculate the target's default size and also size and
+     *  position the target's elements. For example changing the <code>gap</code>
+     *  property on a <code>VerticalLayout</code> will internally call this method
+     *  to ensure that the elements are re-arranged with the new setting and the
+     *  target's default size is recomputed.</p> 
+     */
+    private function invalidateTargetSizeAndDisplayList():void
+    {
+        var g:GroupBase = target;
+        if (!g)
+            return;
+
+        g.invalidateSize();
+        g.invalidateDisplayList();
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Overridden methods from LayoutBase
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    override protected function scrollPositionChanged():void
+    {
+        super.scrollPositionChanged();
+        
+        var layoutTarget:GroupBase = target;
+        if (!layoutTarget)
+            return;
+
+        if (useVirtualLayout)
+            layoutTarget.invalidateDisplayList();
+    }
+
+    /**
+     *  @private
+     */
+    override public function measure():void
+    {
+        // Save and restore these values so they're not modified 
+        // as a sideeffect of measure().
+        var savedColumnCount:int = _columnCount;
+        var savedRowCount:int = _rowCount;
+        var savedHorizontalGap:int = _horizontalGap;
+        var savedVerticalGap:int = _verticalGap;
+        var savedColumnWidth:int = _columnWidth;
+        var savedRowHeight:int = _rowHeight; 
+
+        var layoutTarget:GroupBase = target;
+        if (!layoutTarget)
+            return;
+            
+        updateActualValues(layoutTarget.explicitWidth, layoutTarget.explicitHeight);
+
+        // For measure, any explicit overrides for rowCount and columnCount take precedence
+        var columnCount:int = _requestedColumnCount != -1 ? Math.max(1, _requestedColumnCount) : _columnCount;
+        var rowCount:int = _requestedRowCount != -1 ? Math.max(1, _requestedRowCount) : _rowCount;
+        
+        var measuredWidth:Number = 0;
+        var measuredMinWidth:Number = 0;
+        var measuredHeight:Number = 0;
+        var measuredMinHeight:Number = 0;
+        
+        if (columnCount > 0)
+        {
+            measuredWidth = Math.ceil(columnCount * (_columnWidth + _horizontalGap) - _horizontalGap)
+            // measured min size is guaranteed to have enough columns to fit all elements
+            measuredMinWidth = Math.ceil(_columnCount * (_columnWidth + _horizontalGap) - _horizontalGap);
+        }
+            
+        if (rowCount > 0)
+        {
+            measuredHeight = Math.ceil(rowCount * (_rowHeight + _verticalGap) - _verticalGap);
+            // measured min size is guaranteed to have enough rows to fit all elements
+            measuredMinHeight = Math.ceil(_rowCount * (_rowHeight + _verticalGap) - _verticalGap);
+        }
+		_numElementsCached = -1;
+        
+        var hPadding:Number = paddingLeft + paddingRight;
+        var vPadding:Number = paddingTop + paddingBottom;
+
+        layoutTarget.measuredWidth = measuredWidth + hPadding;
+        layoutTarget.measuredMinWidth = measuredMinWidth + hPadding;
+        layoutTarget.measuredHeight = measuredHeight + vPadding;
+        layoutTarget.measuredMinHeight = measuredMinHeight + vPadding;
+
+        _columnCount = savedColumnCount;
+        _rowCount = savedRowCount;
+        _horizontalGap = savedHorizontalGap;
+        _verticalGap = savedVerticalGap;
+        _columnWidth = savedColumnWidth;
+        _rowHeight = savedRowHeight; 
+    }
+
+    /**
+     *  @private 
+     */  
+    override public function getNavigationDestinationIndex(currentIndex:int, navigationUnit:uint, arrowKeysWrapFocus:Boolean):int
+    {
+        if (!target || target.numElements < 1)
+            return -1; 
+            
+        var maxIndex:int = target.numElements - 1;
+
+        // Special case when nothing was previously selected
+        if (currentIndex == -1)
+        {
+            if (navigationUnit == NavigationUnit.UP || navigationUnit == NavigationUnit.LEFT)
+                return arrowKeysWrapFocus ? maxIndex : -1;
+
+            if (navigationUnit == NavigationUnit.DOWN || navigationUnit == NavigationUnit.RIGHT)
+                return 0;    
+        }    
+            
+        // Make sure currentIndex is within range
+        var inRows:Boolean = orientation == TileOrientation.ROWS;
+        currentIndex = Math.max(0, Math.min(maxIndex, currentIndex));
+
+        // Find the current column and row
+        var currentRow:int;
+        var currentColumn:int;
+        if (inRows)
+        {
+            // Is the TileLayout initialized with valid values?
+            if (columnCount == 0 || rowHeight + verticalGap == 0)
+                return currentIndex;
+                    
+            currentRow = currentIndex / columnCount;
+            currentColumn = currentIndex - currentRow * columnCount;
+        }
+        else
+        {
+            // Is the TileLayout initialized with valid values?
+            if (rowCount == 0 || columnWidth + horizontalGap == 0)
+                return currentIndex;
+    
+            currentColumn = currentIndex / rowCount;
+            currentRow = currentIndex - currentColumn * rowCount;
+        }
+        
+        var newRow:int = currentRow;
+        var newColumn:int = currentColumn;
+
+        // Handle user input, almost all range checks are
+        // performed after the calculations, at the end of the method.
+        switch (navigationUnit)
+        {
+            case NavigationUnit.LEFT: 
+            {
+                // If we are at the first column, can
+                // we go to the previous element (last column, previous row)?
+                if (newColumn == 0 && inRows && newRow > 0)
+                {
+                    newRow--;
+                    newColumn = columnCount - 1;
+                }
+                else if (arrowKeysWrapFocus && newColumn == 0 && inRows && newRow == 0)
+                {
+                    newRow = rowCount - 1;
+                    newColumn = columnCount - 1;
+                }
+                else
+                    newColumn--;
+                break;
+            }
+
+            case NavigationUnit.RIGHT:
+            {
+                // If we are at the last column, can
+                // we go to the next element (first column, next row)?
+                if (newColumn == columnCount - 1 && inRows && newRow < rowCount - 1)
+                {
+                    newColumn = 0;
+                    newRow++;
+                }
+                else if (arrowKeysWrapFocus && newColumn == columnCount - 1 && inRows && newRow == rowCount - 1)
+                {
+                    newColumn = 0;
+                    newRow = 0;
+                }
+                else
+                    newColumn++;
+                break;
+            } 
+
+            case NavigationUnit.UP:
+            {
+                // If we are at the first row, can we
+                // go to the previous element (previous column, last row)?
+                if (newRow == 0 && !inRows && newColumn > 0)
+                {
+                    newColumn--;
+                    newRow = rowCount - 1;
+                }
+                else if (arrowKeysWrapFocus && newRow == 0 && !inRows && newColumn == 0)
+                {
+                    newColumn = columnCount - 1;
+                    newRow = rowCount - 1;
+                }
+                else
+                    newRow--;
+                break; 
+            }
+
+            case NavigationUnit.DOWN:
+            {
+                // If we are at the last row, can we
+                // go to the next element (next column, first row)?
+                if (newRow == rowCount - 1 && !inRows && newColumn < columnCount - 1)
+                {
+                    newColumn++;
+                    newRow = 0;
+                }
+                else if (arrowKeysWrapFocus && newRow == rowCount - 1 && !inRows && newColumn == columnCount - 1)
+                {
+                    newColumn = 0;
+                    newRow = 0;
+                }
+                else
+                    newRow++;
+                break; 
+            }
+
+            case NavigationUnit.PAGE_UP:
+            case NavigationUnit.PAGE_DOWN:
+            {
+                // Ensure we have a valid scrollRect as we use it for calculations below
+                var scrollRect:Rectangle = getScrollRect();
+                if (!scrollRect)
+                    scrollRect = new Rectangle(0, 0, target.contentWidth, target.contentHeight);
+                 
+                if (inRows)
+                {
+                    var firstVisibleRow:int = Math.ceil(scrollRect.top / (rowHeight + verticalGap));
+                    var lastVisibleRow:int = Math.floor(scrollRect.bottom / (rowHeight + verticalGap));
+                     
+                    if (navigationUnit == NavigationUnit.PAGE_UP)
+                    {
+                        // Is the current row visible, somewhere in the middle of the scrollRect?
+                        if (firstVisibleRow < currentRow && currentRow <= lastVisibleRow)
+                            newRow = firstVisibleRow;
+                        else                             
+                            newRow = 2 * firstVisibleRow - lastVisibleRow;
+                    } 
+                    else
+                    {
+                        // Is the current row visible, somewhere in the middle of the scrollRect?
+                        if (firstVisibleRow <= currentRow && currentRow < lastVisibleRow)
+                            newRow = lastVisibleRow;
+                        else                             
+                            newRow = 2 * lastVisibleRow - firstVisibleRow;
+                    }
+                }
+                else
+                {
+                    var firstVisibleColumn:int = Math.ceil(scrollRect.left / (columnWidth + horizontalGap));
+                    var lastVisibleColumn:int = Math.floor(scrollRect.right / (columnWidth + horizontalGap));
+                    
+                    if (navigationUnit == NavigationUnit.PAGE_UP)
+                    {
+                        // Is the current column visible, somewhere in the middle of the scrollRect?
+                        if (firstVisibleColumn < currentColumn && currentColumn <= lastVisibleColumn)
+                            newColumn = firstVisibleColumn;
+                        else    
+                            newColumn = 2 * firstVisibleColumn - lastVisibleColumn; 
+                    }
+                    else
+                    {
+                        // Is the current column visible, somewhere in the middle of the scrollRect?
+                        if (firstVisibleColumn <= currentColumn && currentColumn < lastVisibleColumn)
+                            newColumn = lastVisibleColumn;
+                        else    
+                            newColumn = 2 * lastVisibleColumn - firstVisibleColumn;
+                    }
+                }
+                break; 
+            }
+            default: return super.getNavigationDestinationIndex(currentIndex, navigationUnit, arrowKeysWrapFocus);
+        }
+
+        // Make sure rows and columns are within range
+        newRow = Math.max(0, Math.min(rowCount - 1, newRow));
+        newColumn = Math.max(0, Math.min(columnCount - 1, newColumn));
+
+        // Calculate the new index based on orientation        
+        if (inRows)  
+        {
+            // Make sure we don't return an index for an empty space in the last row.
+            // newRow is guaranteed to be greater than zero:
+            
+            if (newRow == rowCount - 1)
+            {
+                // Step 1: We can end up at the empty space in the last row if we moved right from
+                // the last item.
+                if (currentIndex == maxIndex && newColumn > currentColumn)
+                    newColumn = currentColumn;
+                    
+                // Step 2: We can end up at the empty space in the last row if we moved down from
+                // the previous row.    
+                if (newColumn > maxIndex - columnCount * (rowCount - 1))
+                    newRow--;
+            }
+
+            return newRow * columnCount + newColumn;
+        }
+        else
+        {
+            // Make sure we don't return an index for an empty space in the last column.
+            // newColumn is guaranteed to be greater than zero:
+            
+            if (newColumn == columnCount - 1)
+            {
+                // Step 1: We can end up at the empty space in the last column if we moved down from
+                // the last item.
+                if (currentIndex == maxIndex && newRow > currentRow)
+                    newRow = currentRow;
+                
+                // Step 2: We can end up at the empty space in the last column if we moved right from
+                // the previous column.    
+                if (newRow > maxIndex - rowCount * (columnCount - 1))
+                    newColumn--;
+            }
+
+            return newColumn * rowCount + newRow;
+        }
+    }
+
+    /**
+     *  @private
+     */
+    override public function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
+    {
+        var layoutTarget:GroupBase = target;
+        if (!layoutTarget)
+            return;
+
+        calculateDisplayParameters(unscaledWidth, unscaledHeight);
+        if (useVirtualLayout)
+            updateVirtualLayout(unscaledWidth, unscaledHeight);  // re-calculateDisplayParameters()
+        
+        // Upper right hand corner of first (visibleStartIndex) tile/cell
+        var xPos:Number = visibleStartX;  // paddingLeft if useVirtualLayout=false
+        var yPos:Number = visibleStartY;  // paddingTop if useVirtualLayout=false
+                
+        // Use MajorDelta when moving along the major axis
+        var xMajorDelta:Number;
+        var yMajorDelta:Number;
+
+        // Use MinorDelta when moving along the minor axis
+        var xMinorDelta:Number;
+        var yMinorDelta:Number;
+
+        // Use counter and counterLimit to track when to move along the minor axis
+        var counter:int = 0;
+        var counterLimit:int;
+
+        // Setup counterLimit and deltas based on orientation
+        if (orientation == TileOrientation.ROWS)
+        {
+            counterLimit = _columnCount;
+            xMajorDelta = _columnWidth + _horizontalGap;
+            xMinorDelta = 0;
+            yMajorDelta = 0;
+            yMinorDelta = _rowHeight + _verticalGap;
+        }
+        else
+        {
+            counterLimit = _rowCount;
+            xMajorDelta = 0;
+            xMinorDelta = _columnWidth + _horizontalGap;
+            yMajorDelta = _rowHeight + _verticalGap;
+            yMinorDelta = 0;
+        }
+
+        for (var index:int = visibleStartIndex; index <= visibleEndIndex; index++)
+        {
+            var el:ILayoutElement = null; 
+            if (useVirtualLayout)
+            {
+                el = layoutTarget.getVirtualElementAt(index);
+                if (el is IVisualElement)  // see updateVirtualLayout
+                    IVisualElement(el).visible = true; 
+            }
+            else
+                el = layoutTarget.getElementAt(index);
+
+            if (!el || !el.includeInLayout)
+                continue;
+
+            // To calculate the cell extents as integers, first calculate
+            // the extents and then use Math.round()
+            var cellX:int = Math.round(xPos);
+            var cellY:int = Math.round(yPos);
+            var cellWidth:int = Math.round(xPos + _columnWidth) - cellX;
+            var cellHeight:int = Math.round(yPos + _rowHeight) - cellY;
+
+            sizeAndPositionElement(el, cellX, cellY, cellWidth, cellHeight);
+
+            // Move along the major axis
+            xPos += xMajorDelta;
+            yPos += yMajorDelta;
+
+            // Move along the minor axis
+            if (++counter >= counterLimit)
+            {
+                counter = 0;
+                if (orientation == TileOrientation.ROWS)
+                {
+                    xPos = paddingLeft;
+                    yPos += yMinorDelta;
+                }
+                else
+                {
+                    xPos += xMinorDelta;
+                    yPos = paddingTop;
+                }
+            }
+        }
+
+        var hPadding:Number = paddingLeft + paddingRight;
+        var vPadding:Number = paddingTop + paddingBottom;
+        
+        // Make sure that if the content spans partially over a pixel to the right/bottom,
+        // the content size includes the whole pixel.
+        layoutTarget.setContentSize(Math.ceil(_columnCount * (_columnWidth + _horizontalGap) - _horizontalGap) + hPadding,
+                                    Math.ceil(_rowCount * (_rowHeight + _verticalGap) - _verticalGap) + vPadding);
+
+        // Reset the cache
+        if (!useVirtualLayout)
+            _tileWidthCached = _tileHeightCached = NaN;
+        _numElementsCached = -1;
+        
+        // No getVirtualElementAt() during measure, see calculateVirtualTileSize()
+        if (useVirtualLayout)
+            visibleStartIndex = visibleEndIndex = -1;        
+
+        // If actual values have chnaged, notify listeners
+        dispatchEventsForActualValueChanges();
+    }
+
+    /**
+     *  @private
+     */
+    override public function getElementBounds(index:int):Rectangle
+    {
+        if (!useVirtualLayout)
+            return super.getElementBounds(index);
+
+        var g:GroupBase = GroupBase(target);
+        if (!g || (index < 0) || (index >= g.numElements)) 
+            return null;
+
+        var col:int;
+        var row:int;
+        if (orientation == TileOrientation.ROWS)
+        {
+            col = index % _columnCount;
+            row = index / _columnCount;
+        }
+        else
+        {
+            col = index / _rowCount;
+            row = index % _rowCount
+        }
+        return new Rectangle(leftEdge(col), topEdge(row), _columnWidth, _rowHeight);
+    }
+
+    /**
+     *  @private
+     */
+    override protected function getElementBoundsLeftOfScrollRect(scrollRect:Rectangle):Rectangle
+    {
+        var bounds:Rectangle = new Rectangle();
+        // Find the column that spans or is to the left of the scrollRect left edge.
+        var column:int = Math.floor((scrollRect.left - 1 - paddingLeft) / (_columnWidth + _horizontalGap));
+        bounds.left = leftEdge(column);
+        bounds.right = rightEdge(column);
+        return bounds;
+    }
+
+    /**
+     *  @private
+     */
+    override protected function getElementBoundsRightOfScrollRect(scrollRect:Rectangle):Rectangle
+    {
+        var bounds:Rectangle = new Rectangle();
+        // Find the column that spans or is to the right of the scrollRect right edge.
+        var column:int = Math.floor(((scrollRect.right + 1 + _horizontalGap) - paddingLeft) / (_columnWidth + _horizontalGap));
+        bounds.left = leftEdge(column);
+        bounds.right = rightEdge(column);
+        return bounds;
+    }
+
+    /**
+     *  @private
+     */
+    override protected function getElementBoundsAboveScrollRect(scrollRect:Rectangle):Rectangle
+    {
+        var bounds:Rectangle = new Rectangle();
+        // Find the row that spans or is above the scrollRect top edge
+        var row:int = Math.floor((scrollRect.top - 1 - paddingTop) / (_rowHeight + _verticalGap));
+        bounds.top = topEdge(row);
+        bounds.bottom = bottomEdge(row);
+        return bounds;
+    }
+
+    /**
+     *  @private
+     */
+    override protected function getElementBoundsBelowScrollRect(scrollRect:Rectangle):Rectangle
+    {
+        var bounds:Rectangle = new Rectangle();
+        // Find the row that spans or is below the scrollRect bottom edge
+        var row:int = Math.floor(((scrollRect.bottom + 1 + _verticalGap) - paddingTop) / (_rowHeight + _verticalGap));
+        bounds.top = topEdge(row);
+        bounds.bottom = bottomEdge(row);
+        return bounds;
+    }
+    
+    /**
+     *  @private
+     */
+    override public function elementAdded(index:int):void
+    {
+        invalidateTargetSizeAndDisplayList();
+    }
+    
+    /**
+     *  @private
+     */
+    override public function elementRemoved(index:int):void
+    {
+        invalidateTargetSizeAndDisplayList();
+    }     
+    
+    //--------------------------------------------------------------------------
+    //
+    //  Drop methods
+    //
+    //--------------------------------------------------------------------------
+    
+    /**
+     *  @private 
+     *  Calculates the column and row and returns the corresponding cell index.
+     *  Index may be out of range if there's no element for the cell.
+     */
+    private function calculateDropCellIndex(x:Number, y:Number):Array
+    {
+        var xStart:Number = x - paddingLeft;
+        var yStart:Number = y - paddingTop;
+        var column:int = Math.floor(xStart / (_columnWidth + _horizontalGap));
+        var row:int = Math.floor(yStart / (_rowHeight + _verticalGap));
+        
+        // Check whether x is closer to left column or right column:
+        var midColumnLine:Number;
+        var midRowLine:Number
+        
+        var rowOrientation:Boolean = orientation == TileOrientation.ROWS;
+        if (rowOrientation)
+        {
+            // Mid-line is at the middle of the cell
+            midColumnLine = (column + 1) * (_columnWidth + _horizontalGap) - _horizontalGap - _columnWidth / 2; 
+            
+            // Mid-line is at the middle of the gap between the rows
+            midRowLine = (row + 1) * (_rowHeight + _verticalGap) - _verticalGap / 2;  
+        }
+        else
+        {
+            // Mid-line is at the middle of the gap between the columns
+            midColumnLine = (column + 1) * (_columnWidth + _horizontalGap) - _horizontalGap / 2;
+            
+            // Mid-line is at the middle of the cell
+            midRowLine = (row + 1) * (_rowHeight + _verticalGap) - _verticalGap - _rowHeight / 2; 
+        }
+        
+        if (xStart > midColumnLine)
+            column++;
+        if (yStart > midRowLine)
+            row++;
+        
+        // Limit row and column, if any one is too far from the drop location
+        // And there is white space
+        if (column > _columnCount || row > _rowCount)
+        {
+            row = _rowCount;
+            column = _columnCount;
+        }
+
+        if (column < 0)
+            column = 0;
+        if (row < 0)
+            row = 0;
+        
+        if (rowOrientation)
+        {
+            if (row >= _rowCount)
+                row = _rowCount - 1;
+        }
+        else
+        {
+            if (column >= _columnCount)
+                column = _columnCount - 1;
+        }
+        return [row, column];
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    override protected function calculateDropIndex(x:Number, y:Number):int
+    {
+        var result:Array = calculateDropCellIndex(x, y);
+        var row:int = result[0]; 
+        var column:int = result[1]; 
+        var index:int;
+
+        if (orientation == TileOrientation.ROWS)
+            index = row * _columnCount + column;
+        else
+            index = column * _rowCount + row;
+
+        var count:int = calculateElementCount();
+        _numElementsCached = -1; // Reset the cache
+
+        if (index > count)
+            index = count;
+        return index;
+    }
+    
+    /**
+     *  @inheritDoc
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    override protected function calculateDropIndicatorBounds(dropLocation:DropLocation):Rectangle
+    {
+        var result:Array = calculateDropCellIndex(dropLocation.dropPoint.x, dropLocation.dropPoint.y);
+        var row:int = result[0]; 
+        var column:int = result[1]; 
+
+        var rowOrientation:Boolean = orientation == TileOrientation.ROWS;
+        var count:int = calculateElementCount();
+        _numElementsCached = -1; // Reset the cache
+        
+        if (rowOrientation)
+        {
+            // The last row may be only partially full,
+            // don't drop beyond the last column.
+            if (row * _columnCount + column > count)
+                column = count - (_rowCount - 1) * _columnCount;
+        }
+        else
+        {
+            // The last column may be only partially full,
+            // don't drop beyond the last row.
+            if (column * _rowCount + row > count)
+                row = count - (_columnCount - 1) * _rowCount;
+        }
+        
+        var x:Number;
+        var y:Number;
+        var dropIndicatorElement:IVisualElement;
+        var emptySpace:Number; // empty space between the elements
+
+        // Start with the dropIndicator dimensions, in case it's not 
+        // an IVisualElement
+        var width:Number = dropIndicator.width;
+        var height:Number = dropIndicator.height;
+
+        if (rowOrientation)
+        {
+            emptySpace = (0 < _horizontalGap ) ? _horizontalGap : 0; 
+            var emptySpaceLeft:Number = column * (_columnWidth + _horizontalGap) - emptySpace;
+            
+            // Special case - if we have negative gap and we're the last column,
+            // adjust the emptySpaceLeft
+            if (_horizontalGap < 0 && (column == _columnCount || count == dropLocation.dropIndex))
+                emptySpaceLeft -= _horizontalGap;
+
+            width = emptySpace;
+            height = _rowHeight;
+            // Special case - if we have negative gap and we're not the last
+            // row, adjust the height
+            if (_verticalGap < 0 && row < _rowCount - 1)
+                height += _verticalGap + 1;
+            
+            if (dropIndicator is IVisualElement)
+            {
+                dropIndicatorElement = IVisualElement(dropIndicator);
+                width = Math.max(Math.min(width,
+                                          dropIndicatorElement.getMaxBoundsWidth(false)),
+                                          dropIndicatorElement.getMinBoundsWidth(false));
+            }
+            
+            x = emptySpaceLeft + Math.round((emptySpace - width) / 2) + paddingLeft;
+            // Allow 1 pixel overlap with container border
+            x = Math.max(-1, Math.min(target.contentWidth - width + 1, x));
+
+            y = row * (_rowHeight + _verticalGap) + paddingTop;
+        }
+        else
+        {
+            emptySpace = (0 < _verticalGap ) ? _verticalGap : 0; 
+            var emptySpaceTop:Number = row * (_rowHeight + _verticalGap) - emptySpace;
+            
+            // Special case - if we have negative gap and we're the last column,
+            // adjust the emptySpaceLeft
+            if (_verticalGap < 0 && (row == _rowCount || count == dropLocation.dropIndex))
+                emptySpaceTop -= _verticalGap;
+
+            width = _columnWidth;
+            height = emptySpace;
+            // Special case - if we have negative gap and we're not the last
+            // column, adjust the width
+            if (_horizontalGap < 0 && column < _columnCount - 1)
+                width += _horizontalGap + 1;
+
+            if (dropIndicator is IVisualElement)
+            {
+                dropIndicatorElement = IVisualElement(dropIndicator);
+                height = Math.max(Math.min(emptySpace,
+                                           dropIndicatorElement.getMaxBoundsWidth(false)),
+                                           dropIndicatorElement.getMinBoundsWidth(false));
+            }
+
+            x = column * (_columnWidth + _horizontalGap) + paddingLeft;
+         
+            y = emptySpaceTop + Math.round((emptySpace - height) / 2) + paddingTop;
+            // Allow 1 pixel overlap with container border
+            y = Math.max(-1, Math.min(target.contentHeight - height + 1, y));
+        }
+        
+        return new Rectangle(x, y, width, height);
+    }
+    
+    /**
+     *  @private
+     *  Helper function to return the row and column of the cell 
+     *  containing the x/y point.  The associated index may be out 
+     *  of range if there's no element for the cell.
+     */
+    private function calculateCellIndex(x:Number, y:Number):Array
+    {
+        var xStart:Number = x - paddingLeft;
+        var yStart:Number = y - paddingTop;
+        var column:int = Math.floor(xStart / (_columnWidth + _horizontalGap));
+        var row:int = Math.floor(yStart / (_rowHeight + _verticalGap));
+        
+        // Make sure column and row numbers are valid
+        if (column < 0)
+            column = 0;
+        if (column >= _columnCount)
+            column = _columnCount - 1;
+        if (row < 0)
+            row = 0;
+        if (row >= _rowCount)
+            row = _rowCount - 1;
+        
+        return [row, column];
+    }
+    
+
+    /**
+     *  @private
+     *  Identifies the element which has its "compare point" located closest 
+     *  to the specified position.
+     */
+    override mx_internal function getElementNearestScrollPosition(
+        position:Point,
+        elementComparePoint:String = "center"):int
+    {
+        // Determine which cell contains the point        
+        var result:Array = calculateCellIndex(position.x, position.y);
+        var row:int = result[0]; 
+        var column:int = result[1]; 
+        
+        var maxRow:int = _rowCount-1; 
+        var maxColumn:int = _columnCount-1;
+        
+        // create a rectangle of the element bounds
+        var bounds:Rectangle = 
+            new Rectangle(leftEdge(column), topEdge(row), _columnWidth + _horizontalGap, _rowHeight + _verticalGap);
+
+        const TOP_LEFT:int = 0;
+        const TOP_RIGHT:int = 1;
+        const BOTTOM_LEFT:int = 2;
+        const BOTTOM_RIGHT:int = 3;
+        
+        // Determine the quadrant of the element/cell which contains the position point.
+        var quadrant:int = TOP_LEFT;
+        if (position.x > bounds.left + bounds.width/2)
+            quadrant += TOP_RIGHT;
+        if (position.y > bounds.top + bounds.height/2)
+            quadrant += BOTTOM_LEFT;
+        
+        var index:int;
+        if (orientation == TileOrientation.ROWS)
+            index = row * _columnCount + column;
+        else
+            index = column * _rowCount + row;
+        
+        var g:GroupBase = GroupBase(target);
+        if (index >= g.numElements)
+        {
+            // TODO (eday): two-dimensional item snapping will require more sophisticated cell detection
+            // if the position is beyond the content.  For now (while we only support one-dimensional
+            // snapping), using the last element will work fine.
+            return g.numElements - 1;
+        }
+        
+        // Depending on which point of the element is to be compared with, and on which 
+        // quadrant of the element contains the position, we may adjust row/column to
+        // points to an adjacent cell.
+        switch (elementComparePoint)
+        {
+            case "topLeft":
+                if (quadrant == TOP_RIGHT && column < maxColumn)
+                    column++;
+                else if (quadrant == BOTTOM_LEFT && row < maxRow)
+                    row++;
+                else if (quadrant == BOTTOM_RIGHT && row < maxRow && column < maxColumn)
+                {
+                    row++;
+                    column++;
+                }
+                break;
+            case "topRight":
+                if (quadrant == TOP_LEFT && column > 0)
+                    column--;
+                else if (quadrant == BOTTOM_LEFT && column > 0 && row < maxRow)
+                {
+                    column--;
+                    row++;
+                }
+                else if (quadrant == BOTTOM_RIGHT && row < maxRow)
+                    row++;
+                break;
+            case "bottomLeft":
+                if (quadrant == TOP_LEFT && row > 0)
+                    row--;
+                else if (quadrant == TOP_RIGHT && row > 0 && column < maxColumn)
+                {
+                    row--;
+                    column++;
+                }
+                else if (quadrant == BOTTOM_RIGHT && column < maxColumn)
+                    column++;
+                break;
+            case "bottomRight":
+                if (quadrant == TOP_LEFT && column > 0 && row > 0)
+                {
+                    column--;
+                    row--;
+                }
+                else if (quadrant == TOP_RIGHT && row > 0)
+                    row--;
+                else if (quadrant == BOTTOM_LEFT && column > 0)
+                    column--
+                break;
+            case "center":
+                // for center snapping, "index" is already always the cell with 
+                // its center closest to the specified position
+                break;
+        }
+
+        var newIndex:int;
+        if (orientation == TileOrientation.ROWS)
+            newIndex = row * _columnCount + column;
+        else
+            newIndex = column * _rowCount + row;
+        if (newIndex < g.numElements)
+            index = newIndex;
+        
+        return index;
+    }
+
+}
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/VerticalAlign.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/VerticalAlign.as
new file mode 100644
index 0000000..9f06cc3
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/VerticalAlign.as
@@ -0,0 +1,104 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.layouts
+{
+
+/**
+ *  The VerticalAlign class defines the possible values for the 
+ *  <code>verticalAlign</code> property of the HorizontalLayout class.
+ * 
+ *  @see HorizontalLayout#verticalAlign
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+public final class VerticalAlign
+{   
+    /**
+     *  Vertically align children to the top of the container.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const TOP:String = "top";
+
+    /**
+     *  Vertically align children in the middle of the container.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const MIDDLE:String = "middle";
+
+    /**
+     *  Vertically align children to the bottom of the container.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const BOTTOM:String = "bottom";
+
+    /**
+     *  Justify the children with respect to the container.  This
+     *  uniformly sizes all children to be the same height as the 
+     *  container.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const JUSTIFY:String = "justify";
+
+    /**
+     *  Content justify the children with respect to the container.  This
+     *  uniformly sizes all children to be the content height of the container.
+     *  The content height of the container is the size of the largest child.
+     *  If all children are smaller than the height of the container, then 
+     *  all the children will be sized to the height of the container.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public static const CONTENT_JUSTIFY:String = "contentJustify";
+    
+    /**
+     *  Vertically position the children so that their text is
+     *  aligned to the base line of the container.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 2.5
+     *  @productversion Flex 4.5
+     */
+    public static const BASELINE:String = "baseline";
+}
+
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/VerticalLayout.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/VerticalLayout.as
index ba1fcd2..029ef8d 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/VerticalLayout.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/VerticalLayout.as
@@ -1,2385 +1,2388 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package spark.layouts
-{
-/* import flash.events.Event;
-import flash.geom.Point;
-import flash.geom.Rectangle;
-
-import mx.containers.utilityClasses.Flex;
-import mx.core.FlexVersion;
-import mx.core.ILayoutElement;
-import mx.core.IVisualElement;
-import mx.core.mx_internal;
-import mx.events.PropertyChangeEvent;
-
-import spark.components.DataGroup;
-import spark.components.supportClasses.GroupBase;
-import spark.core.NavigationUnit;
-import spark.layouts.supportClasses.DropLocation;
-import spark.layouts.supportClasses.LayoutBase;
-import spark.layouts.supportClasses.LayoutElementHelper;
-import spark.layouts.supportClasses.LinearLayoutVector;
-
-use namespace mx_internal; */
-
-/**
- *  The VerticalLayout class arranges the layout elements in a vertical sequence,
- *  top to bottom, with optional gaps between the elements and optional padding
- *  around the sequence of elements.
- *
- *  <p>The vertical position of the elements is determined by arranging them
- *  in a vertical sequence, top to bottom, taking into account the padding
- *  before the first element and the gaps between the elements.</p>
- *
- *  <p>The horizontal position of the elements is determined by the layout's
- *  <code>horizontalAlign</code> property.</p>
- *
- *  <p>During the execution of the <code>measure()</code> method, 
- *  the default size of the container is calculated by
- *  accumulating the preferred sizes of the elements, including gaps and padding.
- *  When <code>requestedRowCount</code> is set, only the space for that many elements
- *  is measured, starting from the first element.</p>
- *
- *  <p>During the execution of the <code>updateDisplayList()</code> method, 
- *  the height of each element is calculated
- *  according to the following rules, listed in their respective order of
- *  precedence (element's minimum height and maximum height are always respected):</p>
- *  <ul>
- *    <li>If <code>variableRowHeight</code> is <code>false</code>, 
- *    then set the element's height to the
- *    value of the <code>rowHeight</code> property.</li>
- *
- *    <li>If the element's <code>percentHeight</code> is set, then calculate the element's
- *    height by distributing the available container height between all
- *    elements with a <code>percentHeight</code> setting. 
- *    The available container height
- *    is equal to the container height minus the gaps, the padding and the
- *    space occupied by the rest of the elements. The element's <code>precentHeight</code>
- *    property is ignored when the layout is virtualized.</li>
- *
- *    <li>Set the element's height to its preferred height.</li>
- *  </ul>
- *
- *  <p>The width of each element is calculated according to the following rules,
- *  listed in their respective order of precedence (element's minimum width and
- *  maximum width are always respected):</p>
- *  <ul>
- *    <li>If <code>horizontalAlign</code> is <code>"justify"</code>, 
- *    then set the element's width to the container width.</li>
- *
- *    <li>If <code>horizontalAlign</code> is <code>"contentJustify"</code>,
- *    then set the element's width to the maximum between the container's width 
- *    and all elements' preferred width.</li>
- *
- *    <li>If the element's <code>percentWidth</code> is set, then calculate the element's
- *    width as a percentage of the container's width.</li>
- *
- *    <li>Set the element's width to its preferred width.</li>
- *  </ul>
- *
- *  @mxml 
- *  <p>The <code>&lt;s:VerticalLayout&gt;</code> tag inherits all of the tag 
- *  attributes of its superclass and adds the following tag attributes:</p>
- *
- *  <pre>
- *  &lt;s:VerticalLayout 
- *    <strong>Properties</strong>
- *    gap="6"
- *    horizontalAlign="left"
- *    padding="0"
- *    paddingBottom="0"
- *    paddingLeft="0"
- *    paddingRight="0"
- *    paddingTop="0"
- *    requestedMaxRowCount="-1"
- *    requestedMinRowCount="-1"
- *    requestedRowCount="-1"
- *    rowHeight="<i>calculated</i>"
- *    variableRowHeight="true"
- *    verticalAlign="top"
- *  /&gt;
- *  </pre>
- *
- *  @langversion 3.0
- *  @playerversion Flash 10
- *  @playerversion AIR 1.5
- *  @productversion Flex 4
- */
-public class VerticalLayout
-{ // extends LayoutBase
-    //include "../core/Version.as";
-    
-    /**
-     *  @private
-     *  Cached row heights, max column width for virtual layout.   Not used unless
-     *  useVirtualLayout=true.   See updateLLV(), resetCachedVirtualLayoutState(),
-     *  etc.
-     */
-    /* private var llv:LinearLayoutVector; */
-    
-    //--------------------------------------------------------------------------
-    //
-    //  Class methods
-    //
-    //--------------------------------------------------------------------------
-    
-   /*  private static function calculatePercentWidth(layoutElement:ILayoutElement, width:Number):Number
-    {
-        var percentWidth:Number;
-        if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_6)
-        {
-            percentWidth = LayoutElementHelper.pinBetween(Math.round(layoutElement.percentWidth * 0.01 * width),
-                                                          layoutElement.getMinBoundsWidth(),
-                                                          layoutElement.getMaxBoundsWidth() );
-            return percentWidth < width ? percentWidth : width;
-        }
-        else
-        {
-            percentWidth = LayoutElementHelper.pinBetween(Math.min(Math.round(layoutElement.percentWidth * 0.01 * width), width),
-                                                          layoutElement.getMinBoundsWidth(),
-                                                          layoutElement.getMaxBoundsWidth() );
-            return percentWidth;
-        }
-    } */
-    
-   /*  private static function sizeLayoutElement(layoutElement:ILayoutElement, 
-                                              width:Number, 
-                                              horizontalAlign:String, 
-                                              restrictedWidth:Number, 
-                                              height:Number, 
-                                              variableRowHeight:Boolean, 
-                                              rowHeight:Number):void
-    {
-        var newWidth:Number = NaN;
-        
-        // if horizontalAlign is "justify" or "contentJustify", 
-        // restrict the width to restrictedWidth.  Otherwise, 
-        // size it normally
-        if (horizontalAlign == HorizontalAlign.JUSTIFY ||
-            horizontalAlign == HorizontalAlign.CONTENT_JUSTIFY)
-        {
-            newWidth = restrictedWidth;
-        }
-        else
-        {
-            if (!isNaN(layoutElement.percentWidth))
-               newWidth = calculatePercentWidth(layoutElement, width);
-        }
-        
-        if (variableRowHeight)
-            layoutElement.setLayoutBoundsSize(newWidth, height);
-        else
-            layoutElement.setLayoutBoundsSize(newWidth, rowHeight);
-    } */
-        
-    //--------------------------------------------------------------------------
-    //
-    //  Constructor
-    //
-    //--------------------------------------------------------------------------
-
-    /**
-     *  Constructor. 
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */    
-    public function VerticalLayout():void
-    {
-       // super();
-
-        // Don't drag-scroll in the horizontal direction
-       // dragScrollRegionSizeHorizontal = 0;
-    }
-
-    //--------------------------------------------------------------------------
-    //
-    //  Properties
-    //
-    //--------------------------------------------------------------------------
-
-    //----------------------------------
-    //  gap
-    //----------------------------------
-    
-    private var _gap:int = 6;
-    
-    [Inspectable(category="General")]
-
-    /**
-     *  The vertical space between layout elements, in pixels.
-     * 
-     *  Note that the gap is only applied between layout elements, so if there's
-     *  just one element, the gap has no effect on the layout.
-     * 
-     *  @default 6
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    public function get gap():int
-    {
-        return _gap;
-    }
-
-    /**
-     *  @private
-     */
-    public function set gap(value:int):void
-    {
-        if (_gap == value) 
-            return;
-
-        _gap = value;
-      //  invalidateTargetSizeAndDisplayList();
-    }
-
-    //----------------------------------
-    //  rowCount
-    //----------------------------------
-
-   /*  private var _rowCount:int = -1;
-
-    [Bindable("propertyChange")]
-    [Inspectable(category="General")] */
-    
-    /**
-     *  The current number of visible elements.
-     * 
-     *  @default -1
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    /* public function get rowCount():int
-    {
-        return _rowCount;
-    } */
-    
-    /**
-     *  @private
-     * 
-     *  Sets the <code>rowCount</code> property and dispatches a
-     *  PropertyChangeEvent.
-     */
-   /*  mx_internal function setRowCount(value:int):void
-    {
-        if (_rowCount == value)
-            return;
-        var oldValue:int = _rowCount;
-        _rowCount = value;
-        dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "rowCount", oldValue, value));
-    } */
-    
-    //----------------------------------
-    //  horizontalAlign
-    //----------------------------------
-
-    /**
-     *  @private
-     */
-    private var _horizontalAlign:String = "left"; // HorizontalAlign.LEFT;
-
-    [Inspectable(category="General", enumeration="left,right,center,justify,contentJustify", defaultValue="left")]
-
-    /** 
-     *  The horizontal alignment of layout elements.
-     *  If the value is <code>"left"</code>, <code>"right"</code>, or <code>"center"</code> then the 
-     *  layout element is aligned relative to the container's <code>contentWidth</code> property.
-     * 
-     *  <p>If the value is <code>"contentJustify"</code>, then the layout element's actual
-     *  width is set to the <code>contentWidth</code> of the container.
-     *  The <code>contentWidth</code> of the container is the width of the largest layout element. 
-     *  If all layout elements are smaller than the width of the container, 
-     *  then set the width of all layout elements to the width of the container.</p>
-     * 
-     *  <p>If the value is <code>"justify"</code> then the layout element's actual width
-     *  is set to the container's width.</p>
-     *
-     *  <p>This property does not affect the layout's measured size.</p>
-     *  
-     *  @default "left"
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    public function get horizontalAlign():String
-    {
-        return _horizontalAlign;
-    }
-
-    /**
-     *  @private
-     */
-    public function set horizontalAlign(value:String):void
-    {
-        if (value == _horizontalAlign) 
-            return;
-        
-        _horizontalAlign = value;
-
-        /* var layoutTarget:GroupBase = target;
-        if (layoutTarget)
-            layoutTarget.invalidateDisplayList(); */
-    }
-    
-    //----------------------------------
-    //  verticalAlign
-    //----------------------------------
-    
-    /**
-     *  @private
-     */
-    private var _verticalAlign:String = "top"; //VerticalAlign.TOP;
-    
-    [Inspectable(category="General", enumeration="top,bottom,middle", defaultValue="top")]
-    
-    /** 
-     *  The vertical alignment of the content relative to the container's height.
-     * 
-     *  <p>If the value is <code>"bottom"</code>, <code>"middle"</code>, 
-     *  or <code>"top"</code> then the layout elements are aligned relative 
-     *  to the container's <code>contentHeight</code> property.</p>
-     *
-     *  <p>This property has no effect when <code>clipAndEnableScrolling</code> is true
-     *  and the <code>contentHeight</code> is greater than the container's height.</p>
-     *
-     *  <p>This property does not affect the layout's measured size.</p>
-     *  
-     *  @default "top"
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    public function get verticalAlign():String
-    {
-        return _verticalAlign;
-    }
-    
-    /**
-     *  @private
-     */
-    public function set verticalAlign(value:String):void
-    {
-        if (value == _verticalAlign) 
-            return;
-        
-        _verticalAlign = value;
-        
-       /*  var layoutTarget:GroupBase = target;
-        if (layoutTarget)
-            layoutTarget.invalidateDisplayList(); */
-    }
-	
-	//----------------------------------
-	//  padding
-	//----------------------------------
-	
-	private var _padding:Number = 0;
-	
-	[Inspectable(category="General")]
-	
-	/**
-	 *  The minimum number of pixels between the container's edges and
-	 *  the edges of the layout element.
-	 * 
-	 *  @default 0
-	 *  
-	 *  @langversion 3.0
-	 *  @playerversion Flash 10
-	 *  @playerversion AIR 1.5
-	 *  @productversion Flex 4
-	 */
-	public function get padding():Number
-	{
-		return _padding;
-	}
-	
-	/**
-	 *  @private
-	 */
-	public function set padding(value:Number):void
-	{
-		if (_padding == value)
-			return;
-		
-		_padding = value;
-		
-		paddingBottom = _padding;
-		paddingLeft = _padding;
-		paddingRight = _padding;
-		paddingTop = _padding;
-		
-		//invalidateTargetSizeAndDisplayList();
-	}    
-    
-    //----------------------------------
-    //  paddingLeft
-    //----------------------------------
-
-    private var _paddingLeft:Number = 0;
-    
-    [Inspectable(category="General")]
-
-    /**
-     *  The minimum number of pixels between the container's left edge and
-     *  the left edge of the layout element.
-     * 
-     *  @default 0
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    public function get paddingLeft():Number
-    {
-        return _paddingLeft;
-    }
-
-    /**
-     *  @private
-     */
-    public function set paddingLeft(value:Number):void
-    {
-        if (_paddingLeft == value)
-            return;
-                               
-        _paddingLeft = value;
-       // invalidateTargetSizeAndDisplayList();
-    }    
-    
-    //----------------------------------
-    //  paddingRight
-    //----------------------------------
-
-    private var _paddingRight:Number = 0;
-    
-    [Inspectable(category="General")]
-
-    /**
-     *  The minimum number of pixels between the container's right edge and
-     *  the right edge of the layout element.
-     * 
-     *  @default 0
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    public function get paddingRight():Number
-    {
-        return _paddingRight;
-    }
-
-    /**
-     *  @private
-     */
-    public function set paddingRight(value:Number):void
-    {
-        if (_paddingRight == value)
-            return;
-                               
-        _paddingRight = value;
-       // invalidateTargetSizeAndDisplayList();
-    }    
-    
-    //----------------------------------
-    //  paddingTop
-    //----------------------------------
-
-    private var _paddingTop:Number = 0;
-    
-    [Inspectable(category="General")]
-
-    /**
-     *  Number of pixels between the container's top edge
-     *  and the top edge of the first layout element.
-     * 
-     *  @default 0
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    public function get paddingTop():Number
-    {
-        return _paddingTop;
-    }
-
-    /**
-     *  @private
-     */
-    public function set paddingTop(value:Number):void
-    {
-        if (_paddingTop == value)
-            return;
-                               
-        _paddingTop = value;
-       // invalidateTargetSizeAndDisplayList();
-    }    
-    
-    //----------------------------------
-    //  paddingBottom
-    //----------------------------------
-
-    private var _paddingBottom:Number = 0;
-    
-    [Inspectable(category="General")]
-
-    /**
-     *  Number of pixels between the container's bottom edge
-     *  and the bottom edge of the last layout element.
-     * 
-     *  @default 0
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    public function get paddingBottom():Number
-    {
-        return _paddingBottom;
-    }
-
-    /**
-     *  @private
-     */
-    public function set paddingBottom(value:Number):void
-    {
-        if (_paddingBottom == value)
-            return;
-                               
-        _paddingBottom = value;
-      //  invalidateTargetSizeAndDisplayList();
-    }    
-    
-    //----------------------------------
-    //  requestedMaxRowCount
-    //----------------------------------
-    
-   /*  private var _requestedMaxRowCount:int = -1;
-    
-    [Inspectable(category="General", minValue="-1")] */
-    
-    /**
-     *  The measured height of this layout is large enough to display 
-     *  at most <code>requestedMaxRowCount</code> layout elements. 
-     * 
-     *  <p>If <code>requestedRowCount</code> is set, then
-     *  this property has no effect.</p>
-     *
-     *  <p>If the actual size of the container has been explicitly set,
-     *  then this property has no effect.</p>
-     *
-     *  @default -1
-     *  @see #requestedRowCount
-     *  @see #requestedMinRowCount
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 2.5
-     *  @productversion Flex 4.5
-     */
-   /*  public function get requestedMaxRowCount():int
-    {
-        return _requestedMaxRowCount;
-    } */
-    
-    /**
-     *  @private
-     */
-   /*  public function set requestedMaxRowCount(value:int):void
-    {
-        if (_requestedMaxRowCount == value)
-            return;
-        
-        _requestedMaxRowCount = value;
-        
-        if (target)
-            target.invalidateSize();
-    }    */ 
-    
-    //----------------------------------
-    //  requestedMinRowCount
-    //----------------------------------
-
-    private var _requestedMinRowCount:int = -1;
-    
-    [Inspectable(category="General", minValue="-1")]
-
-    /**
-     *  The measured height of this layout is large enough to display 
-     *  at least <code>requestedMinRowCount</code> layout elements. 
-     * 
-     *  <p>If <code>requestedRowCount</code> is set, then
-     *  this property has no effect.</p>
-     *
-     *  <p>If the actual size of the container has been explicitly set,
-     *  then this property has no effect.</p>
-     *
-     *  @default -1
-     *  @see #requestedRowCount
-     *  @see #requestedMaxRowCount
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 2.5
-     *  @productversion Flex 4.5
-     */
-    public function get requestedMinRowCount():int
-    {
-        return _requestedMinRowCount;
-    }
-
-    /**
-     *  @private
-     */
-    public function set requestedMinRowCount(value:int):void
-    {
-        if (_requestedMinRowCount == value)
-            return;
-                               
-        _requestedMinRowCount = value;
-
-        /* if (target)
-            target.invalidateSize(); */
-    }    
-
-    //----------------------------------
-    //  requestedRowCount
-    //----------------------------------
-    
-    /* private var _requestedRowCount:int = -1;
-    
-    [Inspectable(category="General", minValue="-1")] */
-    
-    /**
-     *  The measured size of this layout is tall enough to display 
-     *  the first <code>requestedRowCount</code> layout elements. 
-     * 
-     *  <p>If <code>requestedRowCount</code> is -1, then the measured
-     *  size will be big enough for all of the layout elements.</p>
-     * 
-     *  <p>If the actual size of the container has been explicitly set,
-     *  then this property has no effect.</p>
-     *
-     *  @default -1
-     *  @see #requestedMinRowCount
-     *  @see #requestedMaxRowCount
-     *
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    /* public function get requestedRowCount():int
-    {
-        return _requestedRowCount;
-    } */
-    
-    /**
-     *  @private
-     */
-    /* public function set requestedRowCount(value:int):void
-    {
-        if (_requestedRowCount == value)
-            return;
-        
-        _requestedRowCount = value;
-        
-        if (target)
-            target.invalidateSize();
-    }    */ 
-
-    //----------------------------------
-    //  rowHeight
-    //----------------------------------
-    
-    /* private var _rowHeight:Number;
-
-    [Inspectable(category="General", minValue="0.0")] */
-
-    /**
-     *  If <code>variableRowHeight</code> is <code>false</code>, then 
-     *  this property specifies the actual height of each child, in pixels.
-     * 
-     *  <p>If <code>variableRowHeight</code> is <code>true</code>, 
-     *  the default, then this property has no effect.</p>
-     * 
-     *  <p>The default value of this property is the preferred height
-     *  of the <code>typicalLayoutElement</code>.</p>
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    /* public function get rowHeight():Number
-    {
-        if (!isNaN(_rowHeight))
-            return _rowHeight;
-        else 
-        {
-            var elt:ILayoutElement = typicalLayoutElement
-            return (elt) ? elt.getPreferredBoundsHeight() : 0;
-        }
-    } */
-
-    /**
-     *  @private
-     */
-    /* public function set rowHeight(value:Number):void
-    {
-        if (_rowHeight == value)
-            return;
-            
-        _rowHeight = value;
-        invalidateTargetSizeAndDisplayList();
-    } */
-    
-    //----------------------------------
-    //  variableRowHeight
-    //----------------------------------
-
-    /**
-     *  @private
-     */
-    /* private var _variableRowHeight:Boolean = true;
-
-    [Inspectable(category="General", enumeration="true,false")] */
-
-    /**
-     *  Specifies whether layout elements are allocated their 
-     *  preferred height.
-     *  Setting this property to <code>false</code> specifies fixed height rows.
-     * 
-     *  <p>If <code>false</code>, the actual height of each layout element is 
-     *  the value of <code>rowHeight</code>.
-     *  Setting this property to <code>false</code> causes the layout to ignore 
-     *  the layout elements' <code>percentHeight</code> property.</p>
-     * 
-     *  @default true
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    /* public function get variableRowHeight():Boolean
-    {
-        return _variableRowHeight;
-    } */
-
-    /**
-     *  @private
-     */
-    /* public function set variableRowHeight(value:Boolean):void
-    {
-        if (value == _variableRowHeight) 
-            return;
-        
-        _variableRowHeight = value;
-        invalidateTargetSizeAndDisplayList();
-    } */
-    
-    //----------------------------------
-    //  firstIndexInView
-    //----------------------------------
-
-    /**
-     *  @private
-     */
-    /* private var _firstIndexInView:int = -1;
-
-    [Inspectable(category="General")]
-    [Bindable("indexInViewChanged")]    */ 
-
-    /**
-     *  The index of the first layout element that is part of the 
-     *  layout and within the layout target's scroll rectangle, or -1 
-     *  if nothing has been displayed yet.
-     *  
-     *  <p>"Part of the layout" means that the element is non-null
-     *  and that its <code>includeInLayout</code> property is <code>true</code>.</p>
-     * 
-     *  <p>Note that the layout element may only be partially in view.</p>
-     * 
-     *  @see fractionOfElementInView()
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    /* public function get firstIndexInView():int
-    {
-        return _firstIndexInView;
-    } */
-    
-    
-    //----------------------------------
-    //  lastIndexInView
-    //----------------------------------
-
-    /**
-     *  @private
-     */
-    /* private var _lastIndexInView:int = -1;
-    
-    [Inspectable(category="General")]
-    [Bindable("indexInViewChanged")]   */  
-
-    /**
-     *  The index of the last row that's part of the layout and within
-     *  the container's scroll rectangle, or -1 if nothing has been displayed yet.
-     * 
-     *  <p>"Part of the layout" means that the child is non-null
-     *  and that its <code>includeInLayout</code> property is <code>true</code>.</p>
-     * 
-     *  <p>Note that the row may only be partially in view.</p>
-     * 
-     *  @see firstIndexInView
-     *  @see fractionOfElementInView
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    /* public function get lastIndexInView():int
-    {
-        return _lastIndexInView;
-    } */
-
-    /**
-     *  Sets the <code>firstIndexInView</code> and <code>lastIndexInView</code>
-     *  properties and dispatches a <code>"indexInViewChanged"</code>
-     *  event.  
-     * 
-     *  @param firstIndex The new value for firstIndexInView.
-     *  @param lastIndex The new value for lastIndexInView.
-     * 
-     *  @see firstIndexInView
-     *  @see lastIndexInview
-     *  
-     *  @private
-     */
-    /* mx_internal function setIndexInView(firstIndex:int, lastIndex:int):void
-    {
-        if ((_firstIndexInView == firstIndex) && (_lastIndexInView == lastIndex))
-            return;
-            
-        _firstIndexInView = firstIndex;
-        _lastIndexInView = lastIndex;
-        dispatchEvent(new Event("indexInViewChanged"));
-    } */
-    
-    //--------------------------------------------------------------------------
-    //
-    //  Methods
-    //
-    //--------------------------------------------------------------------------
-    
-    /**
-     *  @private
-     */
-    /* override public function set clipAndEnableScrolling(value:Boolean):void
-    {
-        super.clipAndEnableScrolling = value;
-        var vAlign:String = verticalAlign;
-        if (vAlign == VerticalAlign.MIDDLE || vAlign == VerticalAlign.BOTTOM)
-        {
-            var g:GroupBase = target;
-            if (g)
-                g.invalidateDisplayList();
-        }
-    } */
-
-    /**
-     * @private
-     */
-    /* override public function clearVirtualLayoutCache():void
-    {
-        llv = null;
-
-        var g:GroupBase = GroupBase(target);
-        if (!g)
-            return;
-        
-        target.invalidateSize();
-        target.invalidateDisplayList();
-    }   */   
-
-    /**
-     *  @private
-     */
-    /* override public function getElementBounds(index:int):Rectangle
-    {
-        if (!useVirtualLayout)
-            return super.getElementBounds(index);
-
-        var g:GroupBase = GroupBase(target);
-        if (!g || (index < 0) || (index >= g.numElements) || !llv) 
-            return null;
-
-        // We need a valid LLV for this function
-        updateLLV(g);
-		
-        return llv.getBounds(index);
-    } */
-	
-    /**
-     *  Returns 1.0 if the specified index is completely in view, 0.0 if
-     *  it's not, or a value between 0.0 and 1.0 that represents the percentage 
-     *  of the if the index that is partially in view.
-     * 
-     *  <p>An index is "in view" if the corresponding non-null layout element is 
-     *  within the vertical limits of the container's <code>scrollRect</code>
-     *  and included in the layout.</p>
-     *  
-     *  <p>If the specified index is partially within the view, the 
-     *  returned value is the percentage of the corresponding
-     *  layout element that's visible.</p>
-     *
-     *  @param index The index of the row.
-     * 
-     *  @return The percentage of the specified element that's in view.
-     *  Returns 0.0 if the specified index is invalid or if it corresponds to
-     *  null element, or a ILayoutElement for which 
-     *  the <code>includeInLayout</code> property is <code>false</code>.
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Flex 4
-     */
-    /* public function fractionOfElementInView(index:int):Number 
-    {
-        var g:GroupBase = GroupBase(target);
-        if (!g)
-            return 0.0;
-            
-        if ((index < 0) || (index >= g.numElements))
-           return 0.0;
-           
-        if (!clipAndEnableScrolling)
-            return 1.0;
-
-           
-        var r0:int = firstIndexInView;  
-        var r1:int = lastIndexInView;
-        
-        // outside the visible index range
-        if ((r0 == -1) || (r1 == -1) || (index < r0) || (index > r1))
-            return 0.0;
-
-        // within the visible index range, but not first or last            
-        if ((index > r0) && (index < r1))
-            return 1.0;
-
-        // get the layout element's Y and Height
-        var eltY:Number;
-        var eltHeight:Number;
-        if (useVirtualLayout)
... 7341 lines suppressed ...