4 Replies Latest reply on Mar 10, 2010 9:32 PM by TanweerHq

    OnChange

    GeorgeWS Level 1

      I have a combobox on my main when I select a supplier I want the Supplier Component to Run its init() with the new supplier number. I cannot figure out how the componet knows when/how to fire the init() that would fire of my RO with the new SupplierID.

       

      My main has a combobox and this local, to bring in the component:

       

      <local:SupplierContent/>

       

      So change the Combobox and the above would reload with the new supplier number. The RO and init() are all in the SupplierContent.

       

      Any thoughts?

      Thanks

       

      George

        • 1. Re: OnChange
          Arun Lal

          in the change handler of your combobox you can create new instance of SupplierContent with the new selected supplier number.

           

          private function changeHandler():void{

               var supplierContentObj:SupplierContent = new SupplierContent();

               this.addChild(supplierContentObj)

          }

          • 2. Re: OnChange
            GeorgeWS Level 1

            I like what you are showing me. I apply the code you shared with me and it adds another instance of the of the component. If I select another it adds another. How do I get rid of the old component. Also I do not see how this triggers the init() in the component?

             

            Thanks

             

            George

            • 3. Re: OnChange
              Arun Lal Level 2

              private function changeHandler():void{

                   if(supplierContentObj){

                        this.removeChild(supplierContentObj);

                        supplierContentObj = null;

                   }

                   var supplierContentObj:SupplierContent = new SupplierContent();

                   this.addChild(supplierContentObj);

              }

               

              Whenever a new instance of a component is created, the creationComplete event is dispatched. So, assuming that init() is the creationComplete eventHandler, this will also be called on every new instance creation.

              • 4. Re: OnChange
                TanweerHq Level 2

                Simple...

                 

                private function comboChangehandler():void

                {

                         this.addChild(s1)

                         s1.init();

                }

                 

                <local:SupplierContent id ="s1"/>

                 

                 

                thats it...