Flex how to use addChild () and removeChild () function to dynamically add or remove Accordion container project? ?

Category: Java EE
 
linhanju2309
2013-03-14 06:54:48

Sponsored Links
Flex how to use addChild () and removeChild () function to dynamically add or remove Accordion container project? ?

Sponsored Links

leiyu_shi1024
2013-03-14 07:11:32

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">
 
    <mx:Script>
        <![CDATA[
            import mx.containers.VBox;
 
            private const MAX_CHILDREN:uint = 5;
 
            private function accordion_addChild():void {
                if (accordion.numChildren < MAX_CHILDREN) {
                    var vbox:VBox = new VBox();
                    vbox.label = "child " + accordion.numChildren;
                    vbox.percentWidth = 100;
                    vbox.percentHeight = 100;
                    var randColor:uint = Math.random() * 0xFFFFFF;
                    vbox.setStyle("backgroundColor", randColor);
                    accordion.addChild(vbox);
                }
            }
 
            private function accordion_deleteChild():void {
                if (accordion.selectedChild) {
                    accordion.removeChild(accordion.selectedChild);
                }
            }
        ]]>
    </mx:Script>
 
    <mx:ApplicationControlBar dock="true">
        <mx:Button label="Add child"
            click="accordion_addChild();" />
        <mx:Button label="Delete child"
            click="accordion_deleteChild();" />
    </mx:ApplicationControlBar>
 
    <mx:Accordion id="accordion" width="240" height="160" />
 
</mx:Application>


Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.