Flex Image control as Button
Thursday 8 May 2008 @ 6:15 pm

You want your Image to behave like a Button with a hand-cursor?
Set buttonMode and useHandCursor to “true” and that’s it:

[Bindable]
[Embed(source="/path/to/my/image.png")]
private var myIcon:Class;
 
private function handleImageClick(event:Event):void
{
// your click handler code
}
 
<mx:Image source="{myIcon}" useHandCursor="true" buttonMode="true" click="handleImageClick(event)" />
- Posted in Flex by Sönke  




2 Responses to 'Flex Image control as Button'

  1. Max - May 9th, 2008 at 12:38 am

    Yeah, you have to set BOTH too, which is what a spent an hour of my life figuring out a while back.

  2. Lanny - May 9th, 2008 at 6:06 am

    You can do this with most components, just make sure that you also set the mouseChildren to false if the component has children. Particularly if the component has a text child, like Label.


Leave a Reply