<?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>Monkey Magician &#187; Flex</title>
	<atom:link href="http://www.monkeymagician.co.uk/category/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.monkeymagician.co.uk</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 16 Jun 2010 12:14:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting Page Title from the &lt;mx:HTML&gt; Component</title>
		<link>http://www.monkeymagician.co.uk/2010/06/16/getting-page-title-mx-html/</link>
		<comments>http://www.monkeymagician.co.uk/2010/06/16/getting-page-title-mx-html/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 12:10:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[air]]></category>

		<guid isPermaLink="false">http://www.monkeymagician.co.uk/?p=43</guid>
		<description><![CDATA[I recently found out how to get the title (i.e. the contents of &#60;title&#62;) of the current page in an &#60;mx:HTML&#62; component in Flex. Turns out you have to wait for the complete event rather than the htmlDOMInitialize event or the value is not accessible.

&#60;mx:Script&#62;
	&#60;![CDATA[

		private function onHtmlComplete():void {
			var title:String = html.domWindow.document.title;
		}

	]]&#62;
&#60;/mx:Script&#62;

&#60;mx:HTML id="html" complete="onHtmlComplete()" /&#62;

Every time [...]]]></description>
			<content:encoded><![CDATA[<p>I recently found out how to get the title (i.e. the contents of &lt;title&gt;) of the current page in an &lt;mx:HTML&gt; component in Flex. Turns out you have to wait for the complete event rather than the htmlDOMInitialize event or the value is not accessible.</p>
<pre class="code">
&lt;mx:Script&gt;
	&lt;![CDATA[

		private function onHtmlComplete():void {
			var title:String = html.domWindow.document.title;
		}

	]]&gt;
&lt;/mx:Script&gt;

&lt;mx:HTML id="html" complete="onHtmlComplete()" /&gt;
</pre>
<p>Every time a new page is loaded this event fires and it is possible to get the new title.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monkeymagician.co.uk/2010/06/16/getting-page-title-mx-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strange URLs when using the Flex SWFLoader</title>
		<link>http://www.monkeymagician.co.uk/2009/08/24/strange-urls-flex-loader/</link>
		<comments>http://www.monkeymagician.co.uk/2009/08/24/strange-urls-flex-loader/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 08:29:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.monkeymagician.co.uk/?p=30</guid>
		<description><![CDATA[I was recently working on a Flex application that had to import a third-party SWF and use its API. Conversely, it needed to access the stage and add children. It threw up an interesting problem with strange import URLs that I finally solved.
I started with the following:
&#60;mx:SWFloader source="http://www.example.com/external.swf" complete="loadComplete(event)" /&#62;
The first security sandbox error was [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently working on a Flex application that had to import a third-party SWF and use its API. Conversely, it needed to access the stage and add children. It threw up an interesting problem with strange import URLs that I finally solved.<span id="more-30"></span></p>
<p>I started with the following:</p>
<pre class="code">&lt;mx:SWFloader source="http://www.example.com/external.swf" complete="loadComplete(event)" /&gt;</pre>
<p>The first security sandbox error was about external.swf not being able to access the stage property. A quick view of the SWFLoader documentation lead to adding the trustContent property:</p>
<pre class="code">&lt;mx:SWFloader source="http://www.example.com/external.swf" complete="loadComplete(event)" trustContent="true" /&gt;</pre>
<p>After switching debugging to a local server on http://flex so that it wasn&#8217;t running in the local security sandbox, the stage error went away.</p>
<p>However, I ended up with a very strange URL not found error along the lines of &#8216;Error #2035: URL Not Found. URL: http://flex/[[IMPORT]]/www.example.com/external2.swf&#8217;. Looked like the third-party SWF was in turn trying to load a further SWF. After discussions with the developers, it turned out they were loading another SWF from the same location by using the LoaderInfo.url property.</p>
<p>Digging around in the SWFLoader source, reading lots of documentation about Flash&#8217;s security model and lots of unsuccessful searching lead me to what appears to be an undocumented feature. When the external content was imported into my application&#8217;s SecurityDomain the loader URL is changed to the one shown above with [[import]] in it. This means that their URL building was failing to produce the correct URL.</p>
<p>The solution was to remove the trustContent property so that the content wasn&#8217;t loaded into the security domain. Initially the stage error came back but by adding Security.allowDomain(&#8216;www.example.com&#8217;) allowed the loaded SWF access to the stage. The same could have been achieved with a crossdomain.xml, I would have thought.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monkeymagician.co.uk/2009/08/24/strange-urls-flex-loader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>System Tray Icon and Menu for an Adobe Flex AIR Application</title>
		<link>http://www.monkeymagician.co.uk/2009/04/22/system-tray-icon-and-menu-for-an-adobe-flex-air-application/</link>
		<comments>http://www.monkeymagician.co.uk/2009/04/22/system-tray-icon-and-menu-for-an-adobe-flex-air-application/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 19:20:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[dock]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[system tray]]></category>

		<guid isPermaLink="false">http://www.monkeymagician.co.uk/2009/04/22/system-tray-icon-and-menu-for-an-adobe-flex-air-application/</guid>
		<description><![CDATA[Adobe AIR allows you to set up a system tray icon and context menu for your application. In true AIR &#38; Flex style, this is surprisingly simple to achieve and doesn&#8217;t even require a .ico file.
Creating the System Tray Icon
Within the WindowedApplication we can embed a graphic to be used as the icon. I&#8217;m using [...]]]></description>
			<content:encoded><![CDATA[<p>Adobe AIR allows you to set up a system tray icon and context menu for your application. In true AIR &amp; Flex style, this is surprisingly simple to achieve and doesn&#8217;t even require a .ico file.<span id="more-29"></span></p>
<h3>Creating the System Tray Icon</h3>
<p>Within the WindowedApplication we can embed a graphic to be used as the icon. I&#8217;m using a 16 x 16 PNG with full alpha transparency.</p>
<pre class="code">[Embed(source="icons/tray.png")]

private var TrayIcon:Class;</pre>
<p>By attaching a handler to the initialize event, an instance of the embedded image is created (cast to a Bitmap) and the bitmap data extracted. This data can then be assigned to the array of icons for the application. I&#8217;m also setting the tooltip text. This code is wrapped inside a check that the system support system tray icons.</p>
<pre class="code">if (NativeApplication.supportsSystemTrayIcon) {
    var trayIcon:BitmapData = Bitmap(new TrayIcon()).bitmapData;
    SystemTrayIcon(nativeApplication.icon).bitmaps = [trayIcon];
    SystemTrayIcon(nativeApplication.icon).tooltip = 'This text will appear when hovering over the icon';
}</pre>
<p>The icon also supports event handlers for various ScreenMouseEvent types, meaning you can handle clicks, right clicks and so on, depending on your requirements.</p>
<h3>Creating a Context Menu</h3>
<p>The context menu for the tray icon is created as a standard NativeMenu (with a number of NativeMenuItem items) and then assigned as the menu for the icon. The sample below defined a menu with an exit option which is handled by a separate handler function.</p>
<pre class="code">var menu:NativeMenu = new NativeMenu();

var exitMenuItem:NativeMenuItem = new NativeMenuItem("Exit");
exitMenuItem.addEventListener(Event.SELECT, exitApplication);
menu.addItem(exitMenuItem);

SystemTrayIcon(nativeApplication.icon).menu = menu;</pre>
<p>The menu will now appear on a right click on the tray icon, there is no need to explicitly wire this interaction together.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monkeymagician.co.uk/2009/04/22/system-tray-icon-and-menu-for-an-adobe-flex-air-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
