2 Replies Latest reply on Nov 29, 2010 3:58 AM by Manjurhusen

    how to get reference of application component in anothor component?

    Manjurhusen

      Hello Friends

       

      I have one problem so plz help me.

       

      Thanks in advance.

       

      I have two file one is application and other is component. I have created Dividedbox in application and i put two buttons in component and used component in application. Now i want to change the direction of dividedbox when i click on button. I have written code but not working. Following is my code.

       

      Application file:  test.mxml

       

      <?xml version="1.0" encoding="utf-8"?>

       

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

       

                     xmlns:s="library://ns.adobe.com/flex/spark"

       

                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"  xmlns:ns1="*">

       

          <fx:Script>

       

              <![CDATA[

       

       

       

       

       

              ]]>

       

          </fx:Script>

       

          <fx:Declarations>

       

              <!-- Place non-visual elements (e.g., services, value objects) here -->

       

          </fx:Declarations>

       

       

       

          <mx:DividedBox id="plistdvidebox" direction="vertical" width="100%" >

       

       

       

              <s:Group id="grp_rlpart" width="100%" height="100%">

       

                  <s:layout>

       

                      <s:HorizontalLayout paddingTop="10" paddingLeft="10">

       

                         

       

                      </s:HorizontalLayout>

       

                  </s:layout>

       

                  <s:Label text="Left ot top part"></s:Label>

       

              </s:Group>

       

              <s:Group id="grp_rrpart" width="100%" >

       

                  <s:layout>

       

                      <s:HorizontalLayout paddingTop="10" paddingLeft="10">

       

                         

       

                      </s:HorizontalLayout>

       

                  </s:layout>

       

                  <s:Label text="right or bottom part" />

       

              </s:Group>

       

             

       

          </mx:DividedBox>

       

          <ns1:tc x="90" y="156">

       

          </ns1:tc>

       

         

       

         

       

      </s:Application>

       

       

      Component File : tc.mxml

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
         
         
             
              <fx:Script>
                  <![CDATA[
                      import mx.containers.BoxDirection;

       


                      protected function btnhr_clickHandler(event:MouseEvent):void
                      {
                          var t:test=new test();
                          t.plistdvidebox.direction=BoxDirection.HORIZONTAL;
                      }

       


                      protected function btnvr_clickHandler(event:MouseEvent):void
                      {
                          var t:test=new test();
                          t.plistdvidebox.direction=BoxDirection.VERTICAL;
                         
                      }

       

                  ]]>
              </fx:Script>
             
              <fx:Declarations>
                  <!-- Place non-visual elements (e.g., services, value objects) here -->
              </fx:Declarations>
          <mx:HBox>
             
         
              <s:Button id="btnhr" content="HR" click="btnhr_clickHandler(event)" />
                  <s:Button id="btnvr" content="VR" click="btnvr_clickHandler(event)" />   
          </mx:HBox>

       

      </s:Group>

       

       

       

      Plz tell me how to do this?

       

       

      plz reply me fast.

       

      Thanks

      Manjurhusen