Laxmidi
Laxmidi

Reputation: 2684

Flex: How to Reference What's Been Clicked When Using an ItemRenderer?

I've got a Tilelist and I'm using an ItemRenderer, which is a Button.

I don't understand how to reference what was clicked. So, if the first tile (which is the first Obect) is clicked, how do I know that that particular one was clicked.

<mx:ArrayCollection id="myAC">
    <mx:Array>
    <mx:Object id="first" label="1" />
    <mx:Object label="2" />
    <mx:Object label="3" />
    <mx:Object label="4" />
    </mx:Array>
</mx:ArrayCollection>



ItemRenderer:

<mx:Button xmlns:mx="http://www.adobe.com/2006/mxml"
click="Alert.show( 'This was Clicked')">


<mx:Script>
<![CDATA[
import mx.controls.Alert;
]]>
</mx:Script>

</mx:Button>

Thank you.

-Laxmidi

Upvotes: 0

Views: 167

Answers (1)

JeffryHouser
JeffryHouser

Reputation: 39408

MouseEvent.target will give you the item was was clicked

If you want to access the element in your dataPRovider, you can use the data property in your itemRenderer. Something like this:

<mx:Button xmlns:mx="http://www.adobe.com/2006/mxml" 
click="Alert.show( data['label'] + ' was Clicked')"

Upvotes: 3

Related Questions