             
                 child = contentView.getElementAt(flexChildIndex) as IUIBase;
                 margin = ValuesManager.valuesImpl.getValue(child, "margin");
-                if (margin is Array)
-                {
-                    if (margin.length == 1)
-                        marginLeft = marginTop = marginRight = marginBottom = margin[0];
-                    else if (margin.length <= 3)
-                    {
-                        marginLeft = marginRight = margin[1];
-                        marginTop = marginBottom = margin[0];
-                    }
-                    else if (margin.length == 4)
-                    {
-                        marginLeft = margin[3];
-                        marginBottom = margin[2];
-                        marginRight = margin[1];
-                        marginTop = margin[0];					
-                    }
-                }
-                else if (margin == null)
-                {
-                    marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left");
-                    marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top");
-                    marginRight = ValuesManager.valuesImpl.getValue(child, "margin-right");
-                    marginBottom = ValuesManager.valuesImpl.getValue(child, "margin-bottom");
-                }
-                else
-                {
-                    marginLeft = marginTop = marginBottom = marginRight = margin;
-                }
-                mt = Number(marginTop);
-                if (isNaN(mt))
-                    mt = 0;
-                mb = Number(marginBottom);
-                if (isNaN(mb))
-                    mb = 0;
-                if (marginLeft == "auto")
-                    ml = 0;
-                else
-                {
-                    ml = Number(marginLeft);
-                    if (isNaN(ml))
-                        ml = 0;
-                }
-                if (marginRight == "auto")
-                    mr = 0;
-                else
-                {
-                    mr = Number(marginRight);
-                    if (isNaN(mr))
-                        mr = 0;
-                }
+                marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left");
+                marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top");
+                marginRight = ValuesManager.valuesImpl.getValue(child, "margin-right");
+                marginBottom = ValuesManager.valuesImpl.getValue(child, "margin-bottom");
+                mt = CSSUtils.getTopValue(marginTop, margin, hh);
+                mb = CSSUtils.getTopValue(marginBottom, margin, hh);
+                mr = CSSUtils.getRightValue(marginRight, margin, ww);
+                ml = CSSUtils.getLeftValue(marginLeft, margin, ww);
                 child.y = mt;
                 if (child is ILayoutChild)
                 {

    			{
    				child = contentView.getElementAt(i) as IUIBase;
    				margin = ValuesManager.valuesImpl.getValue(child, "margin");
    				if (margin is Array)
    				{
    					if (margin.length == 1)
    						marginLeft = marginTop = marginRight = marginBottom = margin[0];
    					else if (margin.length <= 3)
    					{
    						marginLeft = marginRight = margin[1];
    						marginTop = marginBottom = margin[0];
    					}
    					else if (margin.length == 4)
    					{
    						marginLeft = margin[3];
    						marginBottom = margin[2];
    						marginRight = margin[1];
    						marginTop = margin[0];					
    					}
    				}
    				else if (margin == null)
    				{
    					marginLeft = ValuesManager.valuesImpl.getValue(child, "margin-left");
    					marginTop = ValuesManager.valuesImpl.getValue(child, "margin-top");
    					marginRight = ValuesManager.valuesImpl.getValue(child, "margin-right");
    					marginBottom = ValuesManager.valuesImpl.getValue(child, "margin-bottom");
    				}
    				else
    				{
    					marginLeft = marginTop = marginBottom = marginRight = margin;
    				}
    				mt = Number(marginTop);
    				if (isNaN(mt))
    					mt = 0;
    				mb = Number(marginBottom);
    				if (isNaN(mb))
    					mb = 0;
    				if (marginLeft == "auto")
    					ml = 0;
    				else
    				{
    					ml = Number(marginLeft);
    					if (isNaN(ml))
    						ml = 0;
    				}
    				if (marginRight == "auto")
    					mr = 0;
    				else
    				{
    					mr = Number(marginRight);
    					if (isNaN(mr))
    						mr = 0;
    				}
                    child.y = mt;
                    if (child is ILayoutChild)
                    {

	import org.apache.flex.core.ValuesManager;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.IEventDispatcher;
    import org.apache.flex.utils.CSSUtils;

    /**
     *  The OneFlexibleChildHorizontalLayout class is a simple layout
