Creating a simple image map in Flex 4

The following example shows how you can create a simple image map in Flex 4 using a Group container with nested Graphic tags and then drawing hit area shapes using the Rect, Ellipse, or Path classes.

The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see To download the latest nightly build of the Flex 4 SDK, see

For more information on getting started with Flex 4 and Flash Builder 4, see the official Adobe Flex Team blog.

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<s:Application name="Spark_Graphic_mouseEnabledWhereTransparent_test"
        <s:Label text="alpha:" />
        <s:HSlider id="sldr"
                minimum="0.0" maximum="1.0"
                snapInterval="0.1" stepSize="0.1" />
            import mx.controls.Alert;
    <s:Group horizontalCenter="0" verticalCenter="0">
        <s:BitmapImage id="img" source="@Embed('fx_appicon-tn.gif')" />
        <s:Graphic buttonMode="true"
                toolTip="Link 1"
            <s:Rect id="hit1"
                    width="20" height="20"
                    x="5" y="5">
                    <s:SolidColor color="red" alpha="{sldr.value}" />
        <s:Graphic buttonMode="true"
                toolTip="Link 2"
            <s:Ellipse id="hit2"
                    width="20" height="20"
                    x="25" y="10">
                    <s:SolidColor color="haloOrange" alpha="{sldr.value}" />
        <s:Graphic buttonMode="true"
                toolTip="Link 3"
            <s:Path id="hit3"
                    data="M 10 0 L 20 20 L 0 20 L 10 0 Z"
                    x="10" y="25">
                    <s:SolidColor color="yellow" alpha="{sldr.value}" />


View source is enabled in the following example.

This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.

8 thoughts on “Creating a simple image map in Flex 4

    1. @Anonymous,

      I don’t have time right now to create a new Flex Project and upload the SWF, but all you need to do is copy/paste the code and embed one image.


  1. Hi,

    Seeing the data for the triangle there. I know it’s off topics, but is there a way to get them automatically from Flash builder for a drawing?

Comments are closed.