dionisius colossus
dionisius colossus

Reputation: 13

how do i pass the id of an image in flex

My application is going to have multiple images..

<mx:Image id="img1" source="@Embed(source='assets/mrute1.jpg')" 
        mouseDown="mouseMoveHandler(event);"/>
<mx:Image id="img2" source="@Embed(source='assets/mrute2.jpg')" 
        mouseDown="mouseMoveHandler(event);"/>
<mx:Image id="img3" source="@Embed(source='assets/mrute3.jpg')" 
        mouseDown="mouseMoveHandler(event);"/>

Then on the function i want to be able to know the id of the image that was currently being clicked. How do i do that?

mouseMoveHandler(event, ??)

Thanks in advance :)

Upvotes: 0

Views: 122

Answers (2)

greggreg
greggreg

Reputation: 12085

mouseMoveHandler(e:MouseEvent) :void {
 var the_image_id:Number = e.currentTarget.id
}

Upvotes: 2

Rhysyngsun
Rhysyngsun

Reputation: 951

All events have a currentTarget property which is a reference to the component that registered the event. In this case that will be the image. You can then access the id property of the image object. No need to pass this in as a separate parameter.

Upvotes: 2

Related Questions