Search Flex Samples

How to know when my itemRenderer is selected

This problem was logged as bug SDK-9846. It didn’t seem that easy for an itemRenderer to know that it was selected so that it can display itself accordingly. However, it is easy for an itemRenderer to know that it’s selected. As mentioned by Alex Harui, in the bug report, here is the simple line that let’s you know:

ListBase(owner).isItemSelected(data)

If you want to change the appearance of your itemRenderer depending on whether it is selected, you should do so using the line above within the updateDisplayList function that you have overridden.

In the following example, the text in the “price” column changes some of its attributes when selected.

Demo: selectExample.swf

Sample Code: selectExample.mxml, MyLabel.as

0 comments:

Related Flex Samples

Learn Flex: Flex Samples | Flex Video Tutorials Flex Examples