Skip to content

Creating Simple Lists

tenaciousflea edited this page Sep 13, 2010 · 7 revisions

One of the most common UI elements to be used in applications is a List. So whats a list really? In OpenPyro, a List is just a UIContainer with a layout (for example: VLayout or HLayout) that can generate itemRenderers repeatedly based on the a collection data (Array, ArrayCollection or XMLCollection). The DefaultListItemRenderer is a convenient class for ItemRenderers which can be extended if you want.

Here is a simple implemetation of a List:


   list = new List();
			
   var cf:ClassFactory = new ClassFactory(DefaultListRenderer);
   cf.properties = {percentUnusedWidth:100, height:25};
   list.itemRenderer = cf;
   list.addEventListener(ListEvent.ITEM_CLICK, onListItemClick)
   list.skin = new AuroraContainerSkin()
			
   list.width = 200
   list.height = 200
   list.x = list.y = 10;
   addChild(list);

This definitely is a little more verbose than ideal and a future revision will set some defaults so that just creating a List sets up the default list itemRenderer with a percentUnusedWidth of 100. It’s marked as a feature in the bug system.

Note that we still use the AuroraContainerSkin class to get the appropriate scrollbars.

Try the sample here
The source can be found here

Known issues:
See known List issues here