4 Replies Latest reply on Nov 8, 2009 3:23 AM by mohammed.fci86

    Please, I need help in this,How to make a tree control appear from right to left ??

    mohammed.fci86

      i working on Arabic project in which we use a tree control and i  want it to display its branches from right to left .

      i tried to rotate it but it doesn't work because the disclosure triangle still appear on the left .

      i ask if there is any thing to mirror the tree control ,and ask if this mirroing will work or not?

        • 1. Re: Please, I need help in this,How to make a tree control appear from right to left ??
          paul.williams Level 4

          You'll need to modify the layout logic of your renderer.

           

          Here's a simple example that extends the default tree renderer and overrides the updateDisplayList method(). It will probably need more work. Set textAlign="right" on your Tree control when you use this renderer. You'll also need to supply a disclosure icon that points in the opposite direction.

           

          package
          {
              import mx.controls.treeClasses.TreeItemRenderer;
              import mx.controls.treeClasses.TreeListData;

           

              public class RightToLeftTreeItemRenderer extends TreeItemRenderer
              {   
                  override protected function updateDisplayList(unscaledWidth:Number,
                                                            unscaledHeight:Number):void
                  {
                      super.updateDisplayList(unscaledWidth, unscaledHeight);
             
                      var startx : Number = data ? TreeListData( listData ).indent : 0;
             
                      startx = unscaledWidth - startx;
             
                      if ( disclosureIcon )
                      {
                          disclosureIcon.x = startx - disclosureIcon.width;
                          startx = disclosureIcon.x;
                      }
                     
                      if ( icon )
                      {
                          icon.x = startx - icon.width;
                      }
                     
                      if ( label )
                      {
                          label.x = 0;
                      }
                  }
              }
          }

          1 person found this helpful
          • 2. Re: Please, I need help in this,How to make a tree control appear from right to left ??
            mohammed.fci86 Level 1

            Hi,

            I tried to define an object of your class RightToLeftTreeItemRenderer and give it to the property itemRendererbut it generates this error

             

            Implicit coercion of a value of type RightToLeftTreeItemRenderer to an unrelated type mx.core:IFactory.

             

            and i can't convert it impicitly .

            so,if you can help me with more explaination to how to use this renderer.

             

            Thank you for your interest

            • 3. Re: Please, I need help in this,How to make a tree control appear from right to left ??
              paul.williams Level 4

              In MXML:

               

              <mx:Tree

                   itemRenderer="RightToLeftTreeItemRenderer"/>

               

              In Actionscript:

               

              myTree.itemRenderer = new ClassFactory( RightToLeftTreeItemRenderer );

              • 4. Re: Please, I need help in this,How to make a tree control appear from right to left ??
                mohammed.fci86 Level 1

                Thank You very much

                 

                Best Wishes

                 

                mohammed shaaban

                Flex Developer

                MarefaTech

                Egypt