5 Replies Latest reply on Nov 22, 2007 11:02 AM by bpapau

    addChild togglebuttonbar

    bpapau
      Trying to add a viewstack child to a tagglebuttonbar,
      private function configkiosk(event:ResultEvent):void
      {
      NumDataType = event.result.XMLCONFIG.NumDataType;

      // sets up the base page
      MainCanvas = new Canvas();
      MainCanvas.id = "Main Canvas";
      MainCanvas.width = 860;
      MainCanvas.height = 800;
      MainCanvas.setStyle("backgroundColor","white");
      MainCanvas.setStyle("horizontalCenter","0");
      MainCanvas.setStyle("verticalCenter","0");
      this.addChild(MainCanvas);

      MainTBB = new ToggleButtonBar();
      MainTBB.setStyle("bottom","0");
      MainTBB.setStyle("horizontalCenter","0");
      MainTBB.setStyle("fontFamily","Arial");
      MainTBB.setStyle("fontSize","24");
      MainTBB.percentHeight = 10;
      MainTBB.percentWidth = 100;
      MainTBB.dataProvider = "MainViewStack";
      MainCanvas.addChild(MainTBB);

      MainViewStack = new ViewStack();
      MainViewStack.id = "MainViewStack";
      MainViewStack.percentHeight = 90;
      MainTBB.addChild(MainViewStack);

      _newCanvas = new Canvas;
      _newCanvas.id = "newcanvas";
      _newCanvas.setStyle("backgroundColor","black");
      _newCanvas.width = 60;
      _newCanvas.height = 80;
      MainViewStack.addChild(_newCanvas);

      _newCanvas = new Canvas;
      _newCanvas.id = "secondcanvas";
      _newCanvas.setStyle("backgroundColor","red");
      _newCanvas.width = 200;
      _newCanvas.height = 80;
      MainViewStack.addChild(_newCanvas);



      }

      How do I add the viewstack as the dataprovider?
        • 1. Re: addChild togglebuttonbar
          Sreenivas R Adobe Employee
          remove this line MainTBB.addChild(MainViewStack);

          and add this MainTBB.dataProvider = MainViewStack;
          • 2. Re: addChild togglebuttonbar
            bpapau Level 1
            Thats great!!

            I hate to be a pain, but I'm jumping from creating a static flex page to a dynamic one using AS, and its a little daunting.

            My current problem is that when I addCHild to the viewstack and then run the file the new canvas's dont show up, even though their label is on the TBB.

            MainViewStack = new ViewStack();
            MainViewStack.id = "MainViewStack";
            MainViewStack.percentHeight = 90;
            MainTBB.dataProvider = MainViewStack;

            _newCanvas = new Canvas;
            _newCanvas.id = "newcanvas";
            _newCanvas.label = "first";
            _newCanvas.setStyle("top","0");
            _newCanvas.setStyle("backgroundColor","black");
            _newCanvas.percentWidth = 100;
            _newCanvas.percentHeight = 90;
            MainViewStack.addChild(_newCanvas)

            _newCanvas = new Canvas;
            _newCanvas.id = "secondcanvas";
            _newCanvas.label = "second";
            _newCanvas.setStyle("top","0");
            _newCanvas.setStyle("backgroundColor","red");
            _newCanvas.percentWidth = 100;
            _newCanvas.percentHeight = 90;
            MainViewStack.addChild(_newCanvas);

            Am I doing something wrong here, because I don't see the different colors show up.

            Is there a good place I can see examples for different kinds of AS in Flex?
            • 3. Re: addChild togglebuttonbar
              Sreenivas R Adobe Employee
              You have missed adding the ViewStack to anything as a child.

              MainCanvas.addChild(MainViewStack); should get you going.

              You need to understand player, flex, MXML and AS before you can jump into serious flex programming in AS.

              • 4. Re: addChild togglebuttonbar
                bpapau Level 1
                That doesn't appear to colve the problem

                MainViewStack = new ViewStack();
                MainViewStack.id = "MainViewStack";
                MainViewStack.percentHeight = 90;
                MainTBB.dataProvider = MainViewStack;
                MainCanvas.addChild(MainViewStack);

                The new canvas' still dont display.
                • 5. Re: addChild togglebuttonbar
                  bpapau Level 1
                  Ok, you dont even want to know the noob mistake I was making!

                  Thanks for your help/