Opening a new window 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

<?xml version="1.0" encoding="utf-8"?>
<mx:Application name="Image_doubleClick_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            import flash.net.navigateToURL;

            private function img_doubleClick(evt:MouseEvent):void {
                var src:String = evt.currentTarget.source;
                var urlReq:URLRequest = new URLRequest(src);
                navigateToURL(urlReq, "_blank");
            }
        ]]>
    </mx:Script>

    <mx:Image id="img1"
            source="http://www.helpexamples.com/flash/images/image1.jpg"
            doubleClickEnabled="true"
            doubleClick="img_doubleClick(event);" />

<mx:Button id="btnId" click="img_doubleClick(event);"/>

</mx:Application>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s