package components { import mx.containers.ViewStack; import mx.core.UIComponent; /** * ExtendedViewStack extends the standard ViewStack class with some additional functionality. **/ public class ExtendedViewStack extends ViewStack { [Bindable] [Inspectable(category="General", enumeration="true,false", defaultValue="false")] /** * Instructs the ViewStack to set the width to the largest child instead of the current child */ public var resizeToMaxWidth:Boolean = false; [Bindable] [Inspectable(category="General", enumeration="true,false", defaultValue="false")] /** * Instructs the ViewStack to set the height to the largest child instead of the current child */ public var resizeToMaxHeight:Boolean = false; /** * Measures all children and sets the measuredWidth and measuredHeights attributes accordingly. **/ override protected function measure() : void { super.measure(); if(resizeToMaxWidth || resizeToMaxHeight) { for each(var obj:Object in getChildren()) { if(obj is UIComponent) { if(resizeToMaxHeight) { var compHeight:Number = UIComponent(obj).getExplicitOrMeasuredHeight(); if(compHeight > measuredHeight) { measuredHeight = measuredMinHeight = compHeight; } } if(resizeToMaxWidth) { var compWidth:Number = UIComponent(obj).getExplicitOrMeasuredWidth(); if(compWidth > measuredWidth) { measuredWidth = measuredMinWidth = compWidth; } } } } } } } }