Opening a new browser window by double clicking an Image control in Flex

The following example shows how you can open a new browser window/tab by double clicking a Flex Image control by setting the doubleClickEnabled property to true and calling the navigateToURL() method

Full code after the jump.


<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<mx:Application name="Image_doubleClick_test"


            private function img_doubleClick(evt:MouseEvent):void {
                var src:String = evt.currentTarget.source;
                var urlReq:URLRequest = new URLRequest(src);
                navigateToURL(urlReq, "_blank");

    <mx:Image id="img1"
            doubleClick="img_doubleClick(event);" />

    <mx:Image id="img2"
            doubleClick="img_doubleClick(event);" />


7 thoughts on “Opening a new browser window by double clicking an Image control in Flex

  1. it works in chrome and mozilla :), not sure about safari.

    you have a great blog there, even though the examples are simple, they save hours of debugging, and looking through the flex docs. keep up the good work.

  2. i recently completed my first paid full flex site…your blog has been a HUGE help in it’s development…..THANX

  3. I have linked using a button and the img tag and they both work for all three browsers. On a side note, I did not use a mouseEvent to trigger the function. Instead I just passed a string to a function and used the string as the site variable of URLRequest object.

  4. hiii..
    can u pls help me to navigate one mxml page to another mxml in flex (if both files are in local system????? pls send code???

  5. This code only opens the image in a browser window. If you provide source as html: – It is webpage. If you provide the source as an image in your local file: It opens that

Comments are closed.