2 Replies Latest reply on Feb 19, 2010 10:32 AM by chieffan

    Flex 3 need help with panels in dynamic tabs

    chieffan Level 1

      I am building an app where the user can add tabs as needed.  Each tab will have 4 panels inside

      it.  I can't get my for loop to build the panels.  It keeps erroring out.

       

      So question is  1) How do I create these with a loop and 2) I am wanting to put data from a data provider in here.  How can I reference the panel in the vbox in the tab control in the future?  Thanks in advance.

       

      PS...any reason why I can't get newPanel.width="100%" to work? Tried multiple ways. Thanks.

       

      private

       

       

       

       

       

      function addNewTab():void{

       

      if(labelText.text!=""){

       

      var newVbox:VBox=new VBox();

       

      var newLabel:Label = new Label();

       

      var newPanel:Panel=new Panel()

       

      newVbox.label=labelText.text;

      dbtabs.numChildren+1

      numChild = dbtabs.numChildren + 1;

       

       

      var i:int

       

      for(i=0;i<4;i++){

      newPanel.title=

       

      "Panel";

      newPanel.layout=

      "absolute";

       

      //newPanel.width="100%";

      newVbox.addChild(newPanel)

       

       

      newVbox.addChild(newPanel)

       

       

      }

      newwLabel.text =

       

      "Content here";

      newVbox.addChild(newLabel);

       

      dbtabs.addChild(newVbox);

       

       

      labelText.text=

      ""

       

      }

       

      else{

      Alert.show(

      "You must enter a tab name")

       

      // validate labelText

      }

      }