<?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>franto.com &#187; ContextMenu</title>
	<atom:link href="http://franto.com/tag/contextmenu/feed/" rel="self" type="application/rss+xml" />
	<link>http://franto.com</link>
	<description></description>
	<lastBuildDate>Mon, 19 Apr 2010 06:19:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>AIR Tip: ContextMenuItem can crash AIR app on Windows</title>
		<link>http://franto.com/air-tip-contextmenuitem-can-crash-air-app-on-windows/</link>
		<comments>http://franto.com/air-tip-contextmenuitem-can-crash-air-app-on-windows/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 11:34:24 +0000</pubDate>
		<dc:creator>Franto</dc:creator>
				<category><![CDATA[AIR Tips]]></category>
		<category><![CDATA[Flash Tips & Tricks]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[ContextMenu]]></category>

		<guid isPermaLink="false">http://www.franto.com/?p=768</guid>
		<description><![CDATA[This is just quick tip for all AIR developers. If you are developing AIR application and you want to use ContextMenu please be aware of possible problem on Windows platform. This is not problem on Mac, and it's not problem in Flash Player (even on Windows). It is problem just in AIR on Windows]]></description>
			<content:encoded><![CDATA[<div class='series_toc'><h3>Table of contents for air-tip</h3><ol><li><a href='http://franto.com/airtips-problem-with-appxml-in-flex-3/' title='AirTip: Problem with app.xml in Flex 3'>AirTip: Problem with app.xml in Flex 3</a></li><li><a href='http://franto.com/airtip-air-application-gained-focus/' title='AirTip: AIR application gained focus'>AirTip: AIR application gained focus</a></li><li><a href='http://franto.com/airtip-list-all-of-your-drives-in-air-application/' title='AirTip: List all of your drives in AIR application'>AirTip: List all of your drives in AIR application</a></li><li><a href='http://franto.com/adobe-air-15-available-in-flex-sdk-nightly-builds/' title='Adobe AIR 1.5 available in Flex SDK Nightly builds'>Adobe AIR 1.5 available in Flex SDK Nightly builds</a></li><li>AIR Tip: ContextMenuItem can crash AIR app on Windows</li><li><a href='http://franto.com/air-tip-flash-movie-is-not-rendered-in-air-15-html-in-fullscreen/' title='AIR Tip: Flash movie is not rendered in AIR 1.5 HTML  in Fullscreen'>AIR Tip: Flash movie is not rendered in AIR 1.5 HTML  in Fullscreen</a></li></ol></div> <p>This is just quick tip for all AIR developers. If you are developing AIR application and you want to use ContextMenu please be aware of possible problem on Windows platform. This is not problem on Mac, and it&#8217;s not problem in Flash Player (even on Windows). It is problem just in AIR on Windows (at least what I have find out till now).</p>
<p>Problem is as follow:</p>
<p>You want to have ContextMenu for some of your item (right click menu). You have created ContextMenu and want to add ContextMenuItem in this way</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> myItem<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ContextMenuItem</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ContextMenuItem</span><span style="color: #000000;">&#40;</span>myItemName<span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>if variable myItemName is initialized or at least is empty string, all is ok. But there can situations when it is null. For example when you want to support multilanguage with ResourceManager, so it&#8217;s not correctly fill up and it&#8217;s null. In that case you AIR will crash and you will not know why, because it&#8217;s works on Mac, it works in FlashPlayer (without AIR), it just doesn work in AIR on Windows platform</p>
<p>So my quick fix was create fix function, like this</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> fixEmptyString<span style="color: #000000;">&#40;</span>val<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>val == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #990000;">''</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">return</span> val;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> myItem<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ContextMenuItem</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ContextMenuItem</span><span style="color: #000000;">&#40;</span>fixEmptyString<span style="color: #000000;">&#40;</span>myItemName<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>This will for sure.</p>
<p>Hope this helps you.</p>
<p><strong>P.S.</strong> I will post this and another useful AIR tips in my <strong><a title="Franto.com Tips &amp; Tricks, useful Flex, AIR, Flash, ActionScript Tips &amp; Tricks" href="http://www.franto.com/frantocom-tips-tricks">Franto.com Tips &amp; Tricks</a></strong>, so do not wait and subscribe to my list, if you find AIR tip this useful&#8230;</p>
 <div class='series_links'><a href='http://franto.com/adobe-air-15-available-in-flex-sdk-nightly-builds/' title='Adobe AIR 1.5 available in Flex SDK Nightly builds'>Previous in series</a> <a href='http://franto.com/air-tip-flash-movie-is-not-rendered-in-air-15-html-in-fullscreen/' title='AIR Tip: Flash movie is not rendered in AIR 1.5 HTML  in Fullscreen'>Next in series</a></div>]]></content:encoded>
			<wfw:commentRss>http://franto.com/air-tip-contextmenuitem-can-crash-air-app-on-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
