开发者

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜