• warning: Parameter 1 to tac_lite_node_grants() expected to be a reference, value given in /home/rbezemer/softwarebyrichard.com/includes/module.inc on line 483.
  • warning: Parameter 2 to gmap_gmap() expected to be a reference, value given in /home/rbezemer/softwarebyrichard.com/includes/module.inc on line 483.
  • warning: Parameter 1 to tac_lite_node_grants() expected to be a reference, value given in /home/rbezemer/softwarebyrichard.com/includes/module.inc on line 483.
  • warning: Parameter 1 to tac_lite_node_grants() expected to be a reference, value given in /home/rbezemer/softwarebyrichard.com/includes/module.inc on line 483.
  • warning: Parameter 1 to tac_lite_node_grants() expected to be a reference, value given in /home/rbezemer/softwarebyrichard.com/includes/module.inc on line 483.
  • warning: Parameter 1 to tac_lite_node_grants() expected to be a reference, value given in /home/rbezemer/softwarebyrichard.com/includes/module.inc on line 483.
  • warning: Parameter 1 to tac_lite_node_grants() expected to be a reference, value given in /home/rbezemer/softwarebyrichard.com/includes/module.inc on line 483.
  • warning: Parameter 1 to tac_lite_node_grants() expected to be a reference, value given in /home/rbezemer/softwarebyrichard.com/includes/module.inc on line 483.

Transparent List in Flex

So I wanted a list that had no layout information, or a List where you could only see the items in the list, no selection colours, no borders, no background, etc... I spent a lot of time racking my brain trying to figure out the best way to do this. Finally out of desperation I looked at the api and a few related blog posts and the answer was simple. Flex provides support for this in the base list class, so just extend the List class and tell it to not draw anything. How simple is that!

Here is the code to do it:

  1. package
  2. {
  3. import mx.controls.List;
  4. import mx.controls.listClasses.IListItemRenderer;
  5.  
  6. public class TransparentList extends List
  7. {
  8. override protected function createChildren():void
  9. {
  10. super.createChildren();
  11.  
  12. setStyle( “backgroundAlpha”,0);
  13. setStyle( “borderStyle”, “none” );
  14. }
  15.  
  16. override protected function drawItem( item:IListItemRenderer,
  17. selected:Boolean=false,
  18. highlighted:Boolean=false,
  19. caret:Boolean=false,
  20. transition:Boolean=false):void
  21. {
  22. super.drawItem(item, false, false, caret, transition);
  23. }
  24. }
  25. }

 

The draw item function allows you to pass a boolean for selected and highlight parameters. very simple and easy fix to what looks at first glance to be a difficult problem. You would think as an old hand at extending the default flash library this would have been the first solution I would have looked at, must be getting lazy in my old age...

Your rating: None Average: 3.7 (15 votes)