<?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; URLRequest</title>
	<atom:link href="http://blog.flexexamples.com/category/urlrequest/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>Launching new browser windows from Flex</title>
		<link>http://blog.flexexamples.com/2007/08/29/launching-new-browser-windows-from-flex/</link>
		<comments>http://blog.flexexamples.com/2007/08/29/launching-new-browser-windows-from-flex/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 22:01:06 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[URLRequest]]></category>
		<category><![CDATA[navigateToURL]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/29/launching-new-browser-windows-from-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can use the navigateToURL() method in the flash.utils package to open new browser windows, or replace the content in the current window.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/navigateToURL_test/main.mxml">View MXML</a></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2007/08/29/launching-new-browser-windows-from-flex/ --&#62; &#60;mx:Application name=&#34;navigateToURL_test&#34; xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; verticalAlign=&#34;middle&#34; backgroundColor=&#34;white&#34;&#62; &#160; &#60;mx:Script&#62; &#60;![CDATA[ import flash.net.navigateToURL; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can use the <code>navigateToURL()</code> method in the flash.utils package to open new browser windows, or replace the content in the current window.</p>
<p>Full code after the jump.</p>
<p><span id="more-145"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/navigateToURL_test/main.mxml">View MXML</a></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/2007/08/29/launching-new-browser-windows-from-flex/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;navigateToURL_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 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 flash.net.navigateToURL;</span>
&nbsp;
<span style="color: #339933;">            private function newWin(url:String):void {</span>
<span style="color: #339933;">                var urlRequest:URLRequest = new URLRequest(url);</span>
<span style="color: #339933;">                navigateToURL(urlRequest, String(comboBox.selectedItem));</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:ApplicationControlBar</span> dock=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> text=<span style="color: #ff0000;">&quot;window:&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ComboBox</span> id=<span style="color: #ff0000;">&quot;comboBox&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:String</span><span style="color: #7400FF;">&gt;</span></span>_blank<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:String</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:String</span><span style="color: #7400FF;">&gt;</span></span>_top<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:String</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:String</span><span style="color: #7400FF;">&gt;</span></span>CustomName<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:String</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:dataProvider</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:ComboBox</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:ApplicationControlBar</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:LinkButton</span> label=<span style="color: #ff0000;">&quot;Go to adobe.com&quot;</span></span>
<span style="color: #000000;">            click=<span style="color: #ff0000;">&quot;newWin('http://www.adobe.com/')&quot;</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/navigateToURL_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/navigateToURL_test/bin/main.html" width="100%" height="120"></iframe></p>
<p>In the previous example you can specify the target window by using the ComboBox control in the docked ApplicationControlBar container at the top. If you specify &#8220;_blank&#8221;, new windows will be created. If you specify &#8220;_top&#8221;, the current window will be replaced with the specified URL. If you specify the third option, &#8220;<em>CustomName</em>&#8220;, a new named window will be created. So clicking the LinkButton control 5 times loads the content into the same window. And of course the <em>CustomName</em> could be anything you wanted. Basically consider this the &#8220;target&#8221; attribute of an HTML &lt;a&gt; tag (as in <code>&lt;a href="http://www.adobe.com/" target="_blank"&gt;Go to adobe.com&lt;/a&gt;</code>).</p>
<p class="alert">When using the <code>navigateToURL()</code> method, it is important to remember that the method takes a URLRequest object, and not a String object.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Launching new browser windows from Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/08/29/launching-new-browser-windows-from-flex/',contentID: 'post-145',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'navigateToURL',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/2007/08/29/launching-new-browser-windows-from-flex/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>Loading files using the URLLoader and URLVariables classes</title>
		<link>http://blog.flexexamples.com/2007/07/28/loading-files-using-the-urlloader-and-urlvariables-classes/</link>
		<comments>http://blog.flexexamples.com/2007/07/28/loading-files-using-the-urlloader-and-urlvariables-classes/#comments</comments>
		<pubDate>Sat, 28 Jul 2007 19:38:32 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[URLLoader]]></category>
		<category><![CDATA[URLRequest]]></category>
		<category><![CDATA[URLVariables]]></category>
		<category><![CDATA[name/value pairs]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/07/28/loading-files-using-the-urlloader-and-urlvariables-classes/</guid>
		<description><![CDATA[<p>Not sure if this is helpful to anybody, but thought I&#8217;d throw it out there. The following basic example loads some random variables from an external text file and displays the events which were dispatched in a DataGrid control, as well as the loaded name/value pairs.</p> <p>Full code after the jump.</p> <p></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Not sure if this is helpful to anybody, but thought I&#8217;d throw it out there. The following basic example loads some random variables from an external text file and displays the events which were dispatched in a DataGrid control, as well as the loaded name/value pairs.</p>
<p>Full code after the jump.</p>
<p><span id="more-36"></span></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" verticalAlign="middle" backgroundColor="white" creationComplete="init()"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.collections.ArrayCollection;

            [Bindable]
            private var VARIABLES_URL:String = "params.txt";

            [Bindable]
            private var arrColl:ArrayCollection;

            [Bindable]
            private var paramColl:ArrayCollection;

            private var urlReq:URLRequest;
            private var urlLdr:URLLoader;

            private function init():void {
                /* Initialize the two ArrayCollections objects with empty arrays. */
                arrColl = new ArrayCollection();
                paramColl = new ArrayCollection();

                /* Initialize the URLRequest object with the URL to the file of name/value pairs. */
                urlReq = new URLRequest(VARIABLES_URL);

                /* Initialize the URLLoader object, assign the various event listeners, and load the specified URLRequest object. */
                urlLdr = new URLLoader();
                urlLdr.addEventListener(Event.COMPLETE, doEvent);
                urlLdr.addEventListener(Event.OPEN, doEvent);
                urlLdr.addEventListener(HTTPStatusEvent.HTTP_STATUS, doEvent);
                urlLdr.addEventListener(IOErrorEvent.IO_ERROR, doEvent);
                urlLdr.addEventListener(ProgressEvent.PROGRESS, doEvent);
                urlLdr.addEventListener(SecurityErrorEvent.SECURITY_ERROR, doEvent);
                urlLdr.load(urlReq);
            }

            private function doEvent(evt:Event):void {
                arrColl.addItem({type:evt.type, idx:arrColl.length+1, eventString:evt.toString()});

                switch (evt.type) {
                    case Event.COMPLETE:
                        /* If the load was successful, create a URLVariables object from the URLLoader.data property and populate the paramColl ArrayCollection object. */
                        var ldr:URLLoader = evt.currentTarget as URLLoader;
                        var vars:URLVariables = new URLVariables(ldr.data);
                        var key:String;

                        for (key in vars) {
                            paramColl.addItem({key:key, value:vars[key]});
                        }

                        params.visible = true;
                        break;
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:VBox&gt;
        &lt;mx:Label text="Events:" /&gt;
        &lt;mx:DataGrid id="events" dataProvider="{arrColl}" rowCount="5"&gt;
            &lt;mx:columns&gt;
                &lt;mx:DataGridColumn dataField="idx" headerText="#" width="20" /&gt;
                &lt;mx:DataGridColumn dataField="type" headerText="Type" showDataTips="true" dataTipField="eventString" /&gt;
            &lt;/mx:columns&gt;
        &lt;/mx:DataGrid&gt;
    &lt;/mx:VBox&gt;

    &lt;mx:VBox&gt;
        &lt;mx:Label text="Parameters:" /&gt;
        &lt;mx:DataGrid id="params" dataProvider="{paramColl}" rowCount="5" visible="false"&gt;
            &lt;mx:columns&gt;
                &lt;mx:DataGridColumn dataField="key" headerText="Key" /&gt;
                &lt;mx:DataGridColumn dataField="value" headerText="Value" /&gt;
            &lt;/mx:columns&gt;
        &lt;/mx:DataGrid&gt;
    &lt;/mx:VBox&gt;

&lt;/mx:Application&gt;</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Loading files using the URLLoader and URLVariables classes on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/07/28/loading-files-using-the-urlloader-and-urlvariables-classes/',contentID: 'post-36',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'name/value pairs',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/2007/07/28/loading-files-using-the-urlloader-and-urlvariables-classes/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

