<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; link</title>
	<atom:link href="http://blog.flexexamples.com/tag/link/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Adding a link to context menu in Flash Player 10</title>
		<link>http://blog.flexexamples.com/2008/08/26/adding-a-link-to-context-menu-in-flash-player-10/</link>
		<comments>http://blog.flexexamples.com/2008/08/26/adding-a-link-to-context-menu-in-flash-player-10/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 04:28:55 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ContextMenu]]></category>
		<category><![CDATA[URLRequest]]></category>
		<category><![CDATA[link]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/08/26/adding-a-link-to-context-menu-in-flash-player-10/</guid>
		<description><![CDATA[<p>The following example shows how you can add a custom link to a context menu in Flex Gumbo and Flash Player 10 by setting the link and contextMenu properties.</p> <p>Full code after the jump.</p> <p></p> <p class="alert">To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can add a custom link to a context menu in Flex Gumbo and Flash Player 10 by setting the <code>link</code> and <code>contextMenu</code> properties.</p>
<p>Full code after the jump.</p>
<p><span id="more-769"></span></p>
<p class="alert">To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your Flex Builder 3. For more information on downloading and installing the Gumbo SDK into Flex Builder 3, see <a href="http://blog.flexexamples.com/2008/08/02/using-the-beta-gumbo-sdk-in-flex-builder-3/">Using the beta Gumbo SDK in Flex Builder 3&#8243;</a>.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_contextMenu_link_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/26/adding-a-link-to-context-menu-in-flash-player-10/ --&gt;
&lt;Application name="Image_contextMenu_link_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library:adobe/flex/halo"
        xmlns:net="flash.net.*"
        xmlns:ui="flash.ui.*"
        layout="flex.layout.BasicLayout"&gt;

    &lt;mx:Label id="lbl"
            text="Right-click image control for context menu"
            left="10"
            top="10" /&gt;

    &lt;mx:Image id="img"
            source="@Embed('assets/fx_appicon-tn.gif')"
            verticalCenter="0"
            horizontalCenter="0"&gt;
        &lt;mx:contextMenu&gt;
            &lt;ui:ContextMenu id="imageContextMenu"&gt;
                &lt;ui:link&gt;
                    &lt;net:URLRequest url="http://www.adobe.com/go/flex"/&gt;
                &lt;/ui:link&gt;
            &lt;/ui:ContextMenu&gt;
        &lt;/mx:contextMenu&gt;
    &lt;/mx:Image&gt;

&lt;/Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_contextMenu_link_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Image_contextMenu_link_test/bin/main.html" width="100%" height="200"></iframe></p>
<p>You can also set the <code>link</code> and <code>contextMenu</code> properties using ActionScript, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Image_contextMenu_link_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/26/adding-a-link-to-context-menu-in-flash-player-10/ --&gt;
&lt;Application name="Image_contextMenu_link_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library:adobe/flex/halo"
        layout="flex.layout.BasicLayout"
        initialize="init();"&gt;

    &lt;Script&gt;
        &lt;![CDATA[
            [Embed("assets/fx_appicon-tn.gif")]
            private var fxIcon:Class;

            private var imageContextMenu:ContextMenu;
            private var urlReq:URLRequest;

            private function init():void {
                urlReq = new URLRequest();
                urlReq.url = "http://www.adobe.com/go/flex";

                imageContextMenu = new ContextMenu();
                imageContextMenu.link = urlReq;

                lbl.text = "Right-click image control for context menu";
                lbl.setStyle("left", 10);
                lbl.setStyle("top", 10);

                img.source = fxIcon;
                img.setStyle("horizontalCenter", 0);
                img.setStyle("verticalCenter", 0);
                img.contextMenu = imageContextMenu;
            }
        ]]&gt;
    &lt;/Script&gt;

    &lt;mx:Label id="lbl" /&gt;
    &lt;mx:Image id="img" /&gt;

&lt;/Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Adding a link to context menu in Flash Player 10 on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/08/26/adding-a-link-to-context-menu-in-flash-player-10/',contentID: 'post-769',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'link',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/08/26/adding-a-link-to-context-menu-in-flash-player-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding links to a Panel container&#8217;s status text in Flex</title>
		<link>http://blog.flexexamples.com/2008/04/17/adding-links-to-a-panel-containers-status-text-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/04/17/adding-links-to-a-panel-containers-status-text-in-flex/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 02:13:27 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Panel]]></category>
		<category><![CDATA[TextEvent]]></category>
		<category><![CDATA[getStatusTextField()]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[mx internal]]></category>
		<category><![CDATA[selectable]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/04/17/adding-links-to-a-panel-containers-status-text-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can assign an HTML formatted string to a Panel container&#8217;s status text field using the getStatusTextField() method in the mx_internal namespace.</p> <p></p> <p class="alert">Since this example uses the mx_internal namespace, you can&#8217;t always depend on this behavior to work in future versions of the Flex SDK. Use at your [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can assign an HTML formatted string to a Panel container&#8217;s status text field using the <code>getStatusTextField()</code> method in the <code>mx_internal</code> namespace.</p>
<p><span id="more-598"></span></p>
<p class="alert">Since this example uses the <strong>mx_internal</strong> namespace, you can&#8217;t always depend on this behavior to work in future versions of the Flex SDK. Use at your own risk.</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2008/04/17/adding-links-to-a-panel-containers-status-text-in-flex/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;Panel_getStatusTextField_test&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">        layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">        verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">        backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span></span>
<span style="color: #000000;">        creationComplete=<span style="color: #ff0000;">&quot;init();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            import mx.core.IUITextField;</span>
<span style="color: #339933;">            import mx.controls.Alert;</span>
&nbsp;
<span style="color: #339933;">            private function init():void {</span>
<span style="color: #339933;">                var tf:IUITextField = panel.mx_internal::getStatusTextField();</span>
<span style="color: #339933;">                tf.selectable = true;</span>
<span style="color: #339933;">                tf.addEventListener(TextEvent.LINK, textField_link);</span>
<span style="color: #339933;">                tf.htmlText = &quot;status with &lt;a href='event:showAlert'&gt;&lt;u&gt;link&lt;/u&gt;&lt;/a&gt;&quot;;</span>
&nbsp;
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function textField_link(evt:TextEvent):void {</span>
<span style="color: #339933;">                Alert.show(&quot;Success! A Panel container with a link in the status text.&quot;, evt.text);</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Panel</span> id=<span style="color: #ff0000;">&quot;panel&quot;</span></span>
<span style="color: #000000;">            title=<span style="color: #ff0000;">&quot;Title&quot;</span></span>
<span style="color: #000000;">            status=<span style="color: #ff0000;">&quot;status with link&quot;</span></span>
<span style="color: #000000;">            width=<span style="color: #ff0000;">&quot;320&quot;</span></span>
<span style="color: #000000;">            height=<span style="color: #ff0000;">&quot;240&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> text=<span style="color: #ff0000;">&quot;Click the link in the Panel container's status bar to launch an Alert control.&quot;</span></span>
<span style="color: #000000;">                width=<span style="color: #ff0000;">&quot;100%&quot;</span> selectable=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ControlBar</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Text</span> htmlText=<span style="color: #ff0000;">&quot;&amp;lt;b&amp;gt;Note:&amp;lt;/b&amp;gt; The status text field must have it's selectable property set to true in order to dispatch the link event.&quot;</span></span>
<span style="color: #000000;">                    width=<span style="color: #ff0000;">&quot;100%&quot;</span> selectable=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:ControlBar</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Panel</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Panel_getStatusTextField_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Panel_getStatusTextField_test/bin/main.html" width="100%" height="300"></iframe></p>
<p class="note">The status text field must have it&#8217;s <code>selectable</code> property set to <code>true</code> in order to dispatch the <code>link</code> event.</p>
<p class="construction">Note that the Panel container&#8217;s status message was initially set to the desired final string, minus any HTML formatting. This ensures that when the status text is created and measured, the HTML formatted text <i>should</i> fit correctly when it is substituted. This may not work if the width of your text changes due to bold fonts or other changes.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Adding links to a Panel container\&#039;s status text in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/04/17/adding-links-to-a-panel-containers-status-text-in-flex/',contentID: 'post-598',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'getStatusTextField(),link,mx internal,selectable',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/04/17/adding-links-to-a-panel-containers-status-text-in-flex/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Listening for the link event in a Flex Label control</title>
		<link>http://blog.flexexamples.com/2008/01/26/listening-for-the-link-event-in-a-flex-label-control/</link>
		<comments>http://blog.flexexamples.com/2008/01/26/listening-for-the-link-event-in-a-flex-label-control/#comments</comments>
		<pubDate>Sat, 26 Jan 2008 08:49:21 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[Label]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[selectable]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/26/listening-for-the-link-event-in-a-flex-label-control/</guid>
		<description><![CDATA[<p>The following example shows how you can use the link event with the Label control in Flex to handle hyperlinks embedded within a string of text. By using the &#8220;event:&#8221; prefix in the href property of an anchor (&#60;a /&#62;) tag, you can handle links within your Flex application, use the ExternalInterface API to call [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can use the <code>link</code> event with the Label control in Flex to handle hyperlinks embedded within a string of text. By using the &#8220;event:&#8221; prefix in the <code>href</code> property of an anchor (&lt;a /&gt;) tag, you can handle links within your Flex application, use the ExternalInterface API to call JavaScript from Flex, or do pretty much whatever else you want.</p>
<p>Full code after the jump.</p>
<p><span id="more-481"></span></p>
<p class="alert">The Label control must have the <code>selectable</code> property set to <code>true</code> to generate the <code>link</code> event.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Label_link_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/01/26/listening-for-the-link-event-in-a-flex-label-control/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Alert;

            private function lbl_initialize():void {
                lbl.htmlText = "For more information on Flex, see &lt;u&gt;&lt;a href='event:flex.org'&gt;http://www.flex.org/&lt;/a&gt;&lt;/u&gt;.";            }

            private function lbl_link(evt:TextEvent):void {
                Alert.show(evt.toString(), evt.text);

                switch (evt.text) {
                    case "flex.org":
                        // You clicked the flex.org link.
                        break;
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Label id="lbl"
            selectable="true"
            initialize="lbl_initialize();"
            link="lbl_link(event);" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Label_link_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Label_link_test/bin/main.html" width="100%" height="150"></iframe></p>
<p>Another useful little tip when dealing with HTML text, is to put your HTML into an external file, and then embed it into your application using &lt;mx:String /&gt;, as seen in the following snippet:</p>
<pre class="code">
<strong style="color:red;">&lt;mx:String id=&quot;str&quot; source=&quot;text.html&quot; /&gt;</strong>

&lt;mx:Label id=&quot;lbl&quot;
        <strong style="color:red;">htmlText=&quot;{str}&quot;</strong>
        selectable=&quot;true&quot;
        link=&quot;lbl_link(event);&quot; /&gt;
</pre>
<p>And then your text.html file would look like the following:</p>
<pre class="code">
&lt;p&gt;For more information on Flex, see &lt;u&gt;&lt;a href="event:flex.org"&gt;http://www.flex.org/&lt;/a&gt;&lt;/u&gt;.&lt;/p&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Listening for the link event in a Flex Label control on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/01/26/listening-for-the-link-event-in-a-flex-label-control/',contentID: 'post-481',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'event,link,selectable',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/01/26/listening-for-the-link-event-in-a-flex-label-control/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

