knowledge.lapasa.net

Greater Toronto Area Flash Platform Developer Blog

Solution: Getting a Spark List’s itemrender instance

Tags:

Problem: A list is visually made up of as many itemrenderers as the height of that control allows. There are times where you want to do an action on a previously itemrenderer focus that is about to be closed or out of focus. The problem is that there needs to be a reference to that old itemrenderer instance when the user selects a new instance.

Solution: On click of the list, remember the previous list.selectedIndex. Then access the list component’s datagroup property. Then extract the itemRenderer

protected function list_clickHandler(event:MouseEvent):void
{
var dataGroup:DataGroup = list.dataGroup;
var itemRenderer:IItemRenderer = dataGroup.getElementAt(list.selectedIndex) as IItemRenderer;
}

Now you can invoke public methods or public properties on that itemrenderer instance

ABOUT THE AUTHOR
Mark Lapasa is an experienced (5yrs+) Flex/Flash/ActionScript Developer. He has product experience developing client-side application software for the Financial CRM and Online Gaming Industries.

Leave a Reply

© 2009 knowledge.lapasa.net. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.