3 Replies Latest reply on Jul 28, 2010 4:27 AM by BhaskerChari

    How to set style for override button styles from another component

    tuliptaurus

      Hi ,

       

           I got 3 buttons for 3 layout options like stacked , one column and two column layout.

       

          They are located in one component

       

      So in component A

                  - button1 , button2 and button3 (assume these are button id's)

       

      How do I access button1 , button2 and button3 from component B

       

      Can someone explain.

       

      Thanks

        • 1. Re: How to set style for override button styles from another component
          BhaskerChari Level 4

          Hi Ajantha,

           

          Can you please tell exactly how your components are laid out ...both your comp A and Comp B....?

           

          Whether these two components are placed in a seperate file or else Whether one component is placed within another...

           

          Thanks,

          Bhasker Chari

          • 2. Re: How to set style for override button styles from another component
            tuliptaurus Level 1

            file1.mxml

             

            <mx:HBox>
                    <mx:Button id="btn1"  styleName="btn1Style"
                        click="btn1func();"/>
                   <mx:Button id="btn2" styleName="btn1Style"
                        click="btn2func();"/>
                   <mx:Button id="btn3" styleName="btn1Style"
                        click="btn3func();"/>
            </mx:HBox>

             

             

            file2.mxml

             

            I have got a function in file2.mxml

             

            public function informLayoutChanged(event:ABCEvent):void 
                        {
                            layoutChanged = true;
                            saveWorkspaceButton.enabled = true;
                            saveWorkMsg.visible = true;
                        }

             

            this function gives a layout changed msg.

             

            So whenever the layout change happens I need to manually set the button styles of btn1, btn2, and btn3 to

             

            btn1.setStyle("styleName", "btnAStyle");

            btn2.setStyle("styleName", "btnBStyle");

            btn3.setStyle("styleName", "btnCStyle");

             

            How do I do that Bhasker ?

            • 3. Re: How to set style for override button styles from another component
              BhaskerChari Level 4

              Hi Ajantha,

               

              Try to dispatch a custom event in the informLayoutChanged() function in file2.mxml and then try to listen this event in the file1.mxml....With in this eventListener you try to set the button styles using the SetStyle() method...This is the cleaner and best approach I think you can use ....

               

               

              Thanks,

              Bhasker Chari