views:

108

answers:

2

I have a Canvas with a VBox in it. As I add items to the VBox, I want the VBox to grow, I want the scrollbar on the Canvas to control the visibility.

How do I accomplish this?

+2  A: 

try setting the VBoxes verticalScrollPolicy to off (false? not sure, whatever the negative option is)

invertedSpear
I tried that. It makes the VBox clip the contents rather than grow the VBox.
ablerman
+2  A: 

Credit to invertedSpear as it was a correct answer, but here's an example that demonstrates it:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">

<mx:Script>
    <![CDATA[
        import mx.controls.Label;

        private function createChild() : DisplayObject {

            var label:Label = new Label();
            label.text = "hello " + container.numChildren;
            return label;

        }

    ]]>
</mx:Script>


<mx:Button label="Add More" click="container.addChild(createChild())" />

<mx:Canvas width="100%" height="100%" backgroundColor="#FF0000">

    <mx:VBox id="container" verticalScrollPolicy="off" backgroundColor="#FFF" backgroundAlpha="0.5">

        <mx:Label text="hello" />

    </mx:VBox>

</mx:Canvas>

</mx:Application>
brindy