2 Replies Latest reply on Feb 25, 2011 9:48 PM by Yozef0

    ⁂ State of ItemRenderer of List gets unbound, even with getCurrentRendererState()   ✿ fxp provided ✿

    Yozef0 Level 1

      I thought the solution here: http://forums.adobe.com/thread/793271  would solve my problem by utilizing getCurrentRendererState(), but then realized once I scroll up & downb, the states of the ItemRenderers get lost.... Play around with the fxp - I intend to place a similar example publicly for others who may stumble on this problem as well.

       

      Find the fxp file here: CustomScrollerList.fxp.zip

       

      The Problem: With an array of 1000 items in a List, each item has a property which sets the inital state of the ItemRenderer. The itemRenderer has other states, naturally the hovered, and selected state which can be possible only to ItemRenderers that are by default set to 'normal'. I have placed a datagrid (for debug) to see what the state of the index of the item should be. All the object's properties of those that should be 'burnt' by default - or 'normal' to be hovered or selected by the user.

      Also notice, that the proper state on initialize, the list shows all as normal, only the supposed (true) state shows, only once you mouse over the item.

      The fxp will make it all clearer.

       

      // This is where the itemRenderer looses the last state it was in, 
      // and gets set to 'torn' just because you scrolled up and down, 
      // not because as the code suggests when the data got first initialized, it was either null or not.
      
      override protected function getCurrentRendererState():String {
      
           var state:String = super.getCurrentRendererState();
           if (state == 'normal') {
                if (data.burnt != null) {
                       state = 'burnt';
                 } else {
                      state = 'normal';
                 }
           } else if (state == 'burnt') {
                 this.mouseEnabled = false;
                 this.mouseChildren = false;
           }
           return state;
      }