 					childInfoArray[numChildren] = childInfo;
 
 					totalPercent -= childInfo.percent;
-					spaceToDistribute -= min;
+                    // Use unused space first before reducing flexible space.
+                    if (unused >= min)
+                    {
+                        unused -= min;
+                    }
+                    else
+                    {
+                        spaceToDistribute -= min - unused;
+                        unused = 0;
+                    }
 					done = false;
 					break;
 				}

		var numChildren:int = childInfoArray.length;
		var flexConsumed:Number; // space consumed by flexible compontents
		var done:Boolean;
		
		// We now do something a little tricky so that we can 
		// support partial filling of the space. If our total
		// percent < 100% then we can trim off some space.
		var unused:Number = spaceToDistribute -
							(spaceForChildren * totalPercent / 100);
		if (unused > 0)
			spaceToDistribute -= unused;

		// Continue as long as there are some remaining flexible children.
		// The "done" flag isn't strictly necessary, except that it catches
		// cases where round-off error causes totalPercent to not exactly

		} 
		while (!done);

		return Math.max(0, Math.floor((spaceToDistribute + unused) - flexConsumed))
	}
	
	/**
