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" 开发者_如何学Pythonsource="@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 :)
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.
mouseMoveHandler(e:MouseEvent) :void {
var the_image_id:Number = e.currentTarget.id
}
精彩评论