views:

22

answers:

1

Hi,

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

+2  A: 

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')"
www.Flextras.com
www.Flextras.com, You've helped me out a few times. Thanks so much!
Laxmidi
Glad to help! Feel free to give me some "up-vote" love at your own discretion.
www.Flextras.com