6 Replies Latest reply on Jun 13, 2007 1:21 PM by Newsgroup_User

    can't change second comboBox

    Level 7
      Hi all,
      I have two canvas in a tab navigator. From my function I can change the
      properties of a comboBox from the first canvas (conbo1_cb) but I can't do it
      for the second one.
      Any way how to do this?
      Why works only for the first canvas?
      Tks
      JFB

      <mx:Script>
      <![CDATA[
      import mx.controls.ComboBox;
      public function setCombos(event:ResultEvent):void
      {
      this.combo1_cb.label = "label1";
      this.combo2_cb.label = "label2";
      }

      ]]>
      </mx:Script>
      .....
      <mx:TabNavigator width="800" height="100%" y="18" horizontalCenter="60">
      <mx:Canvas label="view1" width="100%" height="100%">
      <mx:ComboBox id="combo1_cb" x="148" y="53"></mx:ComboBox>
      </mx:Canvas>
      <mx:Canvas label="view2" width="100%" height="100%">
      <mx:ComboBox id="conbo2_cb" x="148" y="153"></mx:ComboBox>
      </mx:Canvas>
      </mx:TabNavigator>


        • 1. Re: can't change second comboBox
          upshotvideo Level 1
          first of all the 2nd combo box's id is spelled wrong, but that should throw an error:
          conbo2_cb

          Since its in a canvas that has not been initialized yet, it might not know what to change. Try creationPolicy="all" in your tabnavigator tag. This isnt always the best way to go, it defeats a lot of purposes, but it may help you narrow down the problem.
          • 2. Re: can't change second comboBox
            Level 7
            Yes.. it was my wrong spelling trying to recrate the problem here.
            But creationPolicy works... why?
            Can you explain little bit more?
            Tks for you help

            JFB


            "upshotvideo" <webforumsuser@macromedia.com> wrote in message
            news:f4n3hs$rgq$1@forums.macromedia.com...
            > first of all the 2nd combo box's id is spelled wrong, but that should
            > throw an
            > error:
            > conbo2_cb
            >
            > Since its in a canvas that has not been initialized yet, it might not know
            > what to change. Try creationPolicy="all" in your tabnavigator tag. This
            > isnt
            > always the best way to go, it defeats a lot of purposes, but it may help
            > you
            > narrow down the problem.
            >


            • 3. Re: can't change second comboBox
              upshotvideo Level 1
              creationPolicy set to all will initialize all of the tabnavigators children. When thefunction you made runs, the 2nd Canvas has not been initilized, so it doesnt know what component you are talking about so it cant do anything with it.
              • 4. Re: can't change second comboBox
                Level 7
                Great ..Thank you once again.

                JFB

                "upshotvideo" <webforumsuser@macromedia.com> wrote in message
                news:f4ncso$8ek$1@forums.macromedia.com...
                > creationPolicy set to all will initialize all of the tabnavigators
                > children.
                > When thefunction you made runs, the 2nd Canvas has not been initilized, so
                > it
                > doesnt know what component you are talking about so it cant do anything
                > with
                > it.
                >


                • 5. Re: can't change second comboBox
                  ntsiii Level 3
                  A little more detail:
                  The Flex navigation containers all use what is called "deferred instantiation" by default.

                  This means that the child views are not rendererd (do not exist) until a user has navigated to that view. The purpose of this is to improve the percieved performance of the application at start-up. If every view in a complex app must be rendered at start-up, the start-up time can be unacceptably slow.

                  Setting creationPolicy="all" should be considered a short-term fix. The correct way to handle this is to have the child components bind to a central data location, or have initialization code in them to retrieve and set the desired properties.

                  Tracy
                  • 6. Re: can't change second comboBox
                    Level 7
                    Great... This make a lot of sense, Tks

                    JFB

                    "ntsiii" <tspratt@lariatinc.com> wrote in message
                    news:f4pj4i$bn$1@forums.macromedia.com...
                    >A little more detail:
                    > The Flex navigation containers all use what is called "deferred
                    > instantiation"
                    > by default.
                    >
                    > This means that the child views are not rendererd (do not exist) until a
                    > user
                    > has navigated to that view. The purpose of this is to improve the
                    > percieved
                    > performance of the application at start-up. If every view in a complex
                    > app
                    > must be rendered at start-up, the start-up time can be unacceptably slow.
                    >
                    > Setting creationPolicy="all" should be considered a short-term fix. The
                    > correct way to handle this is to have the child components bind to a
                    > central
                    > data location, or have initialization code in them to retrieve and set the
                    > desired properties.
                    >
                    > Tracy
                    >