Posted By

GunnarHKarlsson on 10/05/11


Tagged

ItemRenderer


Versions (?)

force Itemrenderer redraw


 / Published in: ActionScript 3
 

URL: http://9mmedia.com/blog/?p=709

  1. « 9m Descends on 360 Flex DCSmooth Incremental Slider for Flex »
  2. Invalidating a Spark List Component to Redraw All Item Renderers
  3. Published by Javier on September 13, 2010 in Actionscript, AIR, Code, Flex, Flex 4 and Quick Tips. 9 Comments
  4. Tags: code, components, flex, flex 4, how to, quick tips.
  5. A Flex 3 List component has a public method called invalidateList() that invalidates the display list causing all item renderers to be redrawn. In Flex 4 the Spark List component doesn't have this type of method but you can easily achieve the same goal by simply resetting the itemRenderer property temporarily and then restoring it to trigger a redraw. For example:
  6.  
  7. var _itemRenderer:IFactory = myList.itemRenderer;
  8. myList.itemRenderer = null;
  9. myList.itemRenderer = _itemRenderer;
  10.  
  11.  
  12.  
  13. If you have a subclass of the List component you can simply add the following method or make it static and add it to a utlity class.
  14.  
  15. /**
  16. * Forces the list to redraw all item renderers.
  17. */
  18. public function invalidateList():void
  19. {
  20. var _itemRenderer:IFactory = itemRenderer;
  21. itemRenderer = null;
  22. itemRenderer = _itemRenderer;
  23. }
  24.  
  25.  
  26. This becomes quite handy when you have a control (e.g. slider) that when interacted with changes the size of item renderers dynamically.
  27.  
  28. 9 Comments

Report this snippet  

You need to login to post a comment.