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

7 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.

  • SPanks

    Hello,

    I want to have the following effect -

    I have an image. When i click that image, it should get selected. Once that image gets selected it should have the same rotation effect as that of the rotation effect in MS powerpoint.

    Is it possible in Flex Builder 3?

    Please help me fast. It is urgent.

  • setting the mouseChildren to false helped me alot :)

    thnx lanny :)

  • Actually just the buttonMode is enough.

  • sujendra

    Hi,

    Can we make this possible through only action script?

    is it possible to display an image using actionScript?

    Thanks

  • Alanzo

    Thanks, that tip was just what I was looking for.

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="" highlight="">