1 Reply Latest reply on Jun 26, 2010 1:04 AM by sagarneo11

    need help regarding tree control

    sagarneo11

      hello guys,

       

      i m working on one Flex slideshow application and i m using Xml loaded tree control with swf loader for this. i want to create next previus button for nevigate this slideshow but i dont know much about action script... please help me

       

      i will provide u code of my script if you need to correct it or suggest me how to make it.

       

      thanks in advance

      sagar

        • 1. Re: need help regarding tree control
          sagarneo11 Level 1

          here is sourcecode of my file

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" showCloseButton="true" close="PopUpManager.removePopUp(this);" width="1366" height="768" title="Promotions" fontFamily="Verdana" fontSize="13">
              <mx:Script>
                  <![CDATA[
                      import mx.managers.PopUpManager;
                     
                      private function processLogin():void {
                          // Check credentials (not shown) then remove pop up.
                          PopUpManager.removePopUp(this);
                      }
                   import mx.effects.easing.*;
                          
                           //index button script
                   private function toggleBtn(e:MouseEvent):void{
                      if(e.currentTarget.label== 'Open')
                          panelOut.play();
                      else
                         panelIn.play();
                  }
                          import mx.collections.ICollectionView;
                          import mx.events.ListEvent;
                         
                          // tree control script
                      private function tree_itemClick(evt:ListEvent):void {
                          var t:Tree = evt.currentTarget as Tree;
                          var dataObj:Object = evt.itemRenderer.data;
                          var item:Object = Tree(evt.currentTarget).selectedItem;
                          if (dataObj.hasOwnProperty("@src")) {
                              swfLoader.source = dataObj.@src;
                          } else if (t.dataDescriptor.isBranch(t.selectedItem)) {
                              swfLoader.source = null;
                              tree.expandItem(item, !tree.isItemOpen(item), true);
                              panel1.status = "";
                          }
                      }
                      private function tree_labelFunc(item:Object):String {
                          var children:ICollectionView;
                          var suffix:String = "";
                          if (tree.dataDescriptor.isBranch(item)) {
                              children = tree.dataDescriptor.getChildren(item);
                              suffix = " (" + item.children().length() + ")";
                          }
                          return item.@label + suffix;
                      }

           

                      private function swfLoader_complete(evt:Event):void {
                          panel1.status = (swfLoader.bytesTotal/1024).toFixed(2) + 'KB';
                      }

           

                      private function init():void
                          {
                              systemManager.stage.displayState=flash.display.StageDisplayState.FULL_SCREEN;
                          }
                         
                  ]]>
                  </mx:Script>
                  <mx:XML id="dp" source="data/dp.xml" />
                 
             
             <mx:Canvas x="30" y="-1" width="1315" height="725">
             <mx:Panel id="panel1"
                          width="1310"
                          height="712"
                          backgroundColor="white"
                          borderThickness="0"
                          borderThicknessBottom="0"
                          borderThicknessLeft="0"
                          borderThicknessRight="0"
                          borderStyle="none" cornerRadius="0"
                          headerHeight="0" left="2" y="3">
                      <mx:SWFLoader id="swfLoader"
                              scaleContent="true"
                              complete="swfLoader_complete(event);" />
                     
                      <mx:ControlBar>
                      </mx:ControlBar>
                  </mx:Panel>
             </mx:Canvas>

           

          <mx:Move id="panelOut" target="{panel}" xTo="0" effectEnd="btn.label='Close'"
                duration="500"/>
             <mx:Move id="panelIn" target="{panel}" xTo="-283" effectEnd="btn.label='Open'"
                duration="500"/>      

             <mx:Canvas id="panel" width="314" height="725" x="-283" backgroundColor="#00A2FF" verticalCenter="-1">
                <mx:Grid x="10" y="10" width="299">
                   <mx:GridRow width="100%" height="707">
                      <mx:GridItem width="100%" height="100%">
                      <mx:Tree id="tree"
                              dataProvider="{dp}"
                              labelFunction="tree_labelFunc"
                              showRoot="false"
                              width="269"
                              height="706"
                              itemClick="tree_itemClick(event);"  alpha="0.85" backgroundColor="#C0E1FF"/>
                      </mx:GridItem>
                      <mx:GridItem width="22" height="100%" verticalAlign="middle">
                         <mx:LinkButton label="" id="btn" width="22"  height="707"
                                  click="toggleBtn(event)" icon="@Embed(source='assets/index.png')" enabled="true"/>
                         </mx:GridItem>
                   </mx:GridRow>
                </mx:Grid>
                 <!--Add the content of your sliding panel here  -->
                  </mx:Canvas>
          </mx:TitleWindow>