0 Replies Latest reply on Nov 4, 2009 10:34 PM by DavidArcher2

    Tree cellRenderer not working

    DavidArcher2 Level 1

      The following test code adds an asterisk in front of the node labels of a Tree component.

       

      It works in a trivial Flash document but displays blank labels in a much more complex one. In both cases the library contains a Movie Clip with name, linkage identifier and AS 2.0 class all set to "MyTreeCell".

       

      Can anyone suggest why this code may not work, propose an alternative which may work, or provide a strategy for diagnosis?

       

      Thanks!
      David.

       

      Scene:Layer:Frame:

       

      createClassObject(mx.controls.Tree, "myTree", 1);
      myTree.dataProvider = '<node label="Mail"><node label="In"/><node label="Out"/></node>';
      myTree.cellRenderer = "MyTreeCell";

       

      MyTreeCell.as:

       

      class MyTreeCell extends mx.core.UIComponent
      {
        var myCell : TextField;
        var owner;
        var listOwner : MovieClip;  
        var getCellIndex : Function;
        var getDataLabel : Function;

       

        function MyTreeCell()
        {
        }
        function createChildren(Void) : Void
        {
          if (myCell == undefined)
          {
            createLabel("myCell", 1);
            myCell.selectable = false;
          }
        }
        function size(Void) : Void
        {
          myCell.setSize(__width - 2, __height - 2);
        }
        function setValue(str:String, item:Object, sel:Boolean) : Void
        {
          myCell.text = (item == undefined ? "" : "*" + str);
        }
        function getPreferredHeight(Void) : Number
        {
          return myCell.getPreferredHeight();
        }
      }