Apache – Flex list switching itemRender of selected item

adobeapache-flex

In Flex 4 (beta 2), I have a list control populated from an XMLListCollection.

What I would like to do is when an item is selected in the list, use a custom item renderer on the selected item as well as the item that appears just prior to the selected item in the list.

I am using a spark list control, but I am open to alternate components if the solution makes sense.

Here is the strucutre of the xml used to populate the XMLListCollection

<Images>
   <Image>
      <Id>1</Id>
      <Url>http://www.mydomain.com/image1.png</Url>
   </Image>
   <Image>
      <Id>2</Id>
      <Url>http://www.mydomain.com/image2.png</Url>
   </Image>
<Images>

Thank you in advance.

Best Answer

Why not use one itemRenderer which has a number of states which vary based on what the current data is? That would accomplish your goal in a much faster, simpler, and maintainable fashion.

Related Topic