2 Replies Latest reply on Sep 3, 2009 3:16 AM by <patel:tanmay />

    UIComponent override question

    phil1943 Level 1

      within my custom UIComponent when I want to addchildren, should I always be overriding and using the

      protected function createChildren ?

      I notice I can use addChild anywhere without overriding the protected createChildren function and it still works.
      Should I not be doing this ?

      Thanks
        • 1. Re: UIComponent override question
          leybniz Level 4

          It's a good habbit to follow Flex SDK visual components life-cycle, since AS has asynchrounous nature it's better to keep all

          child creation and configuration activities inside overrided createChildren method, this will keep your class more organized and predictable,

          once you are free to addChild anywhere in the code, you could easily get lost in the creation chain and component initialization logic becomes hard to trace for you once component grows up. My advice is to use central spot for creation activity, rather than random placed addChild calls.. this will save you time in future  Good luck

          • 2. Re: UIComponent override question
            <patel:tanmay /> Level 1

            It depends on what purpose you are trying to addChild().

             

            If you are doing that initially while creating the component only then it's better to use createChildren() function, but id you are tring to add child for displayng some data, say like list components or so, then try to use updateDisplayList() method.

             

            cause, as far as I know, createChildren() method gets called when the component it self is added to display list, that is only single time, and updateDisplayList() gets called whenever th component needs to get updated.

             

            Hope, this should help u

            1 person found this helpful