Archive

Archive for June 24, 2008

Hyperlinking In FLEX

Hi,

 

Probably Hyperlinking is one of the most commonly seen thing to navigate to other page.

But to write this post here i thanks to one of mine Orkut friends querry.

 

For such querries i am always welcome.. So lets get on with example

 

The label, text, and textarea controls can dispatch a link event when the user selects a hyperlink in the Htmltext property.

 

About link Event :

 

link : Dispatched when a user clicks a hyperlink in an HTML-enabled text field, where the URL begins with "event:".

 

To generate the link event, prefix the hyperlink destination with event:

 

 As the following example shows

 

<?xml version=”1.0″?>

 

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”

    borderStyle=”solid”

    backgroundGradientColors=”[#FFFFFF, #FFFFFF]“>

   

    <mx:Script>

        <![CDATA[

            import flash.events.TextEvent;

 

            public function linkHandler(event:TextEvent):void {

                myLabel.text="link occured.";

                // Open the link in a new window.

                navigateToURL(new URLRequest(event.text), '_blank');

            }

        ]]>

    </mx:Script>

   

    <mx:Label selectable=”true” link=”linkHandler(event);”>

        <mx:htmlText><![CDATA[<a href='event:http://www.adobe.com'>Adobe</a>]]></mx:htmlText>

    </mx:Label> 

 

    <mx:TextArea id=”myLabel”/>

</mx:Application>

 

 

Thanks and regards

 

Shashank Kulkarni

 

Feel free to mail me J shashank.pawan@gmail.com