Flex Image control as Button

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)" />

2 comments to Flex Image control as Button

  • Max

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

  • 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

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">