1 Reply Latest reply on Sep 19, 2006 2:35 PM by bnambooz

    Tree.iconfunction

    dzlmbq
      I am moving a Flex 1.5 app to 2.0 and am having issues with the tree.iconfunction. The iconfunction does a search against tree labels. If the label is not found I do not see any folders or default flex icons in the tree. In 1.5 I did see the default icons when the iconfunction returned nothing. Anyone have a way to tell Flex 2.0 to use the default tree icons when an icon is not found in a custom iconfunction? Anyone?

      private var leafSymbol:Class;
      [Embed("assets/images/icon_Application.png")]
      private var appSymbol:Class;
      [Embed("assets/images/icon_Home.png")]
      private var homeSymbol:Class;
      [Embed("assets/images/icon_Multimedia.png")]
      private var mediaSymbol:Class;
      [Embed("assets/images/icon_Documents.png")]
      private var docsSymbol:Class;
      [Embed("assets/images/icon_GreenGear.png")]
      private var newSymbol:Class;
      [Embed("assets/images/icon_Author.png")]
      private var authorSymbol:Class;

      private function treeIconFunc(item:Object):Class
      {
      var type:String = item.label;
      var docType:Class;
      switch(type)
      {
      case "Architecture Diagrams":
      docType = appSymbol;
      case "Home":
      docType = homeSymbol;
      case "Multimedia":
      docType = mediaSymbol;
      case "Whitepapers":
      docType = docsSymbol;
      case "New":
      docType = newSymbol;
      }
      //docType = folderClosedIcon;
      return docType;
      }

      <mx:VBox width="100%" height="100%">
      <mx:Tree id="myTree" width="100%" height="100%"
      showRoot="false" dataProvider="{_xmlData}"
      iconFunction="treeIconFunc" labelField="@label"
      itemRenderer="MyTreeItemRenderer" visible="false"/>
      </mx:VBox>
        • 1. Re: Tree.iconfunction
          bnambooz
          The default skins are stored inside Assets.swf, in your frameworks directory, corresponding to each Tree style property as you see in default.css:
          Tree
          {
          defaultLeafIcon: Embed(source="Assets.swf",symbol="TreeNodeIcon");
          disclosureClosedIcon: Embed(source="Assets.swf",symbol="TreeDisclosureClosed");
          disclosureOpenIcon: Embed(source="Assets.swf",symbol="TreeDisclosureOpen");
          folderClosedIcon: Embed(source="Assets.swf",symbol="TreeFolderClosed");
          folderOpenIcon: Embed(source="Assets.swf",symbol="TreeFolderOpen");

          So you need to have a default case at the end of your switch statement, and depending on the folder type and state (branch, leaf, open, closed), return of one the skinds from Assets.swf.

          HTH,
          Belinda