<?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>blackcj.com &#187; Flash</title>
	<atom:link href="http://www.blackcj.com/blog/tag/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blackcj.com/blog</link>
	<description>Cutting edge development with Adobe Flex, ActionScript and AIR</description>
	<lastBuildDate>Thu, 15 Dec 2011 01:01:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Publishing Apps to iOS, Android and BlackBerry with AIR</title>
		<link>http://www.blackcj.com/blog/2011/02/02/publishing-apps-to-ios-android-and-blackberry-with-air/</link>
		<comments>http://www.blackcj.com/blog/2011/02/02/publishing-apps-to-ios-android-and-blackberry-with-air/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 20:44:19 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=942</guid>
		<description><![CDATA[Using Flash Builder Burrito and the Flash IDE you can export your ActionScript projects to three mobile platforms without any change in code! Let's take a look at how to make this possible. Before we get started, here is a video with one of my demo apps running on all three devices: Multi-screen: The variety [...]]]></description>
			<content:encoded><![CDATA[<p>Using <a href="http://labs.adobe.com/technologies/flashbuilder_burrito/" target="_blank">Flash Builder Burrito</a> and the <a href="http://www.adobe.com/products/flash/" target="_blank">Flash IDE</a> you can export your ActionScript projects to three mobile platforms without any change in code! Let's take a look at how to make this possible. Before we get started, here is a video with one of my demo apps running on all three devices:</p>
<p><iframe title="YouTube video player" class="youtube-player" type="text/html" width="480" height="390" src="http://www.youtube.com/embed/HPQxZNiutX8" frameborder="0" allowFullScreen></iframe></p>
<p><strong>Multi-screen:</strong><br />
The variety of screen resolutions and DPIs can be the hardest part of building a mobile app. When building an AIR app for mobile devices you have two important properties Capabilities.screenResolutionX(Y) and <a href="http://renaun.com/blog/2011/01/air-capabilities-screendpi-on-devices/" target="_blank">Capabilities.screenDPI</a>. Using stage.stageWidth on mobile devices does not work the way you would expect it to. If you set up your application in Flash to have a width of 480 and a height of 800, the stageWidth and stageHeight will return these numbers even if the screen is smaller. Another thing to note is that the iOS packager currently targets 320x480 even though many of the iOS devices run 640x960. We'll account for that by adding a screenResolution check.</p>
<p>In my application when a device has lower than 400 pixels in width I drop down the paint brush width. When the device has higher than 400 pixels I increase the size of the menu accordingly. A better approach would be to use the Capabilities.screenDPI for this calculation rather than just the screenResolution. All of your view components should be able to render at different DPIs and resolutions. When you know this from the start it is easy to build into the code. Here is an example:</p>
<div class="igBar"><span id="lactionscript-3"><a href="#" onclick="javascript:showPlainTxt('actionscript-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-3">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Capabilities</span>.<span style="color: #0066CC;">screenResolutionX</span> &lt;<span style="color: #cc66cc;color:#800000;">400</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; _canvas = <span style="color: #000000; font-weight: bold;">new</span> SimplePaint<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Capabilities</span>.<span style="color: #0066CC;">screenResolutionX</span>, <span style="color: #0066CC;">Capabilities</span>.<span style="color: #006600;">screenResolutionY</span>-<span style="color: #cc66cc;color:#800000;">85</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; _canvas.<span style="color: #006600;">ratio</span> = <span style="color: #cc66cc;color:#800000;">0</span>.<span style="color: #cc66cc;color:#800000;">66</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; _canvas = <span style="color: #000000; font-weight: bold;">new</span> SimplePaint<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Capabilities</span>.<span style="color: #0066CC;">screenResolutionX</span>, <span style="color: #0066CC;">Capabilities</span>.<span style="color: #006600;">screenResolutionY</span>-<span style="color: #cc66cc;color:#800000;">125</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; _menuBar.<span style="color: #006600;">scaleX</span> = _menuBar.<span style="color: #006600;">scaleY</span> = <span style="color: #cc66cc;color:#800000;">1</span>.<span style="color: #cc66cc;color:#800000;">5</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Notice how we are changing the size ratio of the brushes for smaller screens with a lower DPI. For larger screens we are increasing the size of the menu. This makes the application appear the same to the end user even when the app is running at 480x800 on the Android and 320x480 on the iOS! This could be improved to use the actual DPI value but the basic idea is there.</p>
<p><strong>Multi-touch</strong><br />
This is the easy part. Use the Multitouch.maxTouchPoints to determine if the device supports touch. If it does than add touch listeners, if the device has 0 touch points <strong>add mouse event listeners</strong>. Don't be that person that only codes for one device. With only a few extra lines of code you app will work on desktop and mobile. This also makes debugging much easier!</p>
<div class="igBar"><span id="lactionscript-4"><a href="#" onclick="javascript:showPlainTxt('actionscript-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-4">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>Multitouch.<span style="color: #006600;">maxTouchPoints</span>&gt; <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Multitouch.<span style="color: #006600;">inputMode</span> = MultitouchInputMode.<span style="color: #006600;">TOUCH_POINT</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; _canvas.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TouchEvent.<span style="color: #006600;">TOUCH_BEGIN</span>, onTouchBegin<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; _canvas.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TouchEvent.<span style="color: #006600;">TOUCH_MOVE</span>, onTouchMove<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; _canvas.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>TouchEvent.<span style="color: #006600;">TOUCH_END</span>, onTouchEnd<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; _canvas.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_DOWN</span>, onMouseBegin<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; _canvas.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_MOVE</span>, onMyMouseMove<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; _canvas.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_UP</span>, onMouseEnd<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Wasn't that easy? One thing to note is that TOUCH_END was not always dispatched, especially when you start using 3+ touch points. To work around this add a timer into your class that checks to see if a TOUCH_MOVE event has been called. The TOUCH_MOVE event is dispatched even when the user has stopped moving and only stops when the touch has ended. As a backup, check every half a second or so to make sure the specific touch point id is still moving.</p>
<p><strong>Setup:</strong><br />
To setup your workspace to export to all three platforms you'll need to create a ActionScript only Mobile project in Flash Builder Burrito. Create an FLA in the source folder that uses the runnable AS file as its base. Create your assets in the FLA file, export them into a SWC to be used for FB and mark them as run time compiled so they work with the Flash IDE. From here you can export to <strong>all three devices without changing any files</strong>. Life is good <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Conclusion:</strong><br />
In just 17 lines of code and a little setup we've got our multi-screen, multi-touch application ready to go! Make sure to add your event listeners for Android to close the app when the user hits back or home. This entire painting application is less than 400 lines of code (~4KB compiled), was built from scratch in less than 12 hours and is easily maintainable across multiple platforms. Performance is great and native APIs are easy to use. My only complaints are that the file size for the iOS is rather large and the iOS exporter doesn't support the Camera API yet. Outside of that, this is the best way to build cross platform apps.</p>
<h3>Wet Paint on the Web:</h3>
<p><script type="text/javascript">// <![CDATA[
 var flashvars = {}; var params = { bgcolor: "ffffff", wmode:"opaque" }; swfobject.embedSWF("http://www.blackcj.com/blog/wp-content/swfs/FlashPaint/FlashPaint.swf", "WetPaint", "400", "400", "9.0.0", "flash/expressInstall.swf", flashvars, params);
// ]]&gt;</script></p>
<div id="WetPaint">
<h1>Wet Paint Flash application.</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></div>
<p>Porting to the web required changing 3 lines of code. To get these source files running on mobile devices change the _webMode value to false and remove the width / height from the SWF declaration. I also had to comment out the cacheAsBitmapMatrix to get it running on the web. Still very easy to convert!</p>
<p><a href="http://www.blackcj.com/blog/wp-content/swfs/FlashPaint/FlashPaint.zip">Source files</a>.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2011/02/02/publishing-apps-to-ios-android-and-blackberry-with-air/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Cut the Drama. Flash is Here to Stay.</title>
		<link>http://www.blackcj.com/blog/2010/02/01/cut-the-drama-flash-is-here-to-stay/</link>
		<comments>http://www.blackcj.com/blog/2010/02/01/cut-the-drama-flash-is-here-to-stay/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 05:00:27 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Myth]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=682</guid>
		<description><![CDATA[I really wish that Steve Jobs would quit misinforming the public. It amazes me that Apple and Adobe's childish feud is even news worthy. I've had a number of people tell me that I should start looking for a new profession because HTML5 is the future and Flash is dead (link). All of them iPhone [...]]]></description>
			<content:encoded><![CDATA[<p>I really wish that Steve Jobs would quit misinforming the public. It amazes me that Apple and Adobe's childish feud is even news worthy. I've had a number of people tell me that I should start looking for a new profession because HTML5 is the future and Flash is dead (<a href="http://www.wired.com/epicenter/2010/01/googles-dont-be-evil-mantra-is-bullshit-adobe-is-lazy-apples-steve-jobs/">link</a>). All of them iPhone users and each of them were just tech savvy enough not to know what the hell they were talking about. Here is ten minutes worth of research to show Steve Jobs' opinion on the matter is a bit more like a leap of blind faith.</p>
<p><a href="http://www.blackcj.com/blog/wp-content/uploads/2010/02/jobgraph.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/02/jobgraph.png" alt="" title="Job Graph" width="540" height="300" class="alignnone size-full wp-image-684" /></a></p>
<p><strong>What does this graph tell us?</strong><br />
Well, even through a recession, ActionScript job growth has held strong. Objective C on the other hand looks very unstable.</p>
<p><a href="http://www.blackcj.com/blog/wp-content/uploads/2010/02/trends.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/02/trends.png" alt="" title="Salary Trends" width="540" height="269" class="alignnone size-full wp-image-685" /></a></p>
<p><strong>And this one?</strong><br />
Nobody seems to be able to make up their mind about how much to pay Objective C programmers. Is it worth more than HTML or not? Would you work in a development language that had the potential for a 50% pay cut if you lost your job?</p>
<p><a href="http://www.blackcj.com/blog/wp-content/uploads/2010/02/Web_development_timeline.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/02/Web_development_timeline-300x248.png" alt="" title="Web Development Timeline" width="300" height="248" class="alignnone size-medium wp-image-686" /></a><br />
<a href="http://www.hiten.net/wilberwind/wordpress/?p=826"><em>http://www.hiten.net/wilberwind/wordpress/?p=826</em></a></p>
<p><strong>How about this chart?</strong><br />
I would like someone to point out the web development language that died. Anyone? Oh wait... none of them have ever died! When somebody comes out with something better, the competition does the same. Not to mention that it took AJAX nearly ten years to catch on. As much as some people hate PHP, it is still around. As much as some people hate Microsoft, .NET is still kicking. As much as Steve Jobs hates Adobe, Flash is here to stay.</p>
<p>Do I hate HTML5 and think it will fail? No. I hope it succeeds. The reason I code ActionScript is because it is widely supported and cutting edge. HTML4 wasn't enough for me. When HTML5 has a 3D engine, physics support, frameworks, blogs of examples, full browser support, and a great IDE, I'll strongly consider it. Until then, please don't tell me I should look for a new profession. </p>
<p>*Update 02/02/2010 @ 7am in response to a comment below*<br />
<a href="http://www.blackcj.com/blog/wp-content/uploads/2010/02/jobgraph_cf1.png"><img src="http://www.blackcj.com/blog/wp-content/uploads/2010/02/jobgraph_cf1.png" alt="" title="ActionScript Job Trends" width="540" height="300" class="alignnone size-full wp-image-703" /></a></p>
<p><strong>Analysis:</strong><br />
Perl seems to be holding strong. I wish the data went back further, was there ever a significant decline? They still have a pretty big market for jobs with a steady incline. Coldfusion jobs have not gone up but have also not really gone down over the past 5 years. That's pretty good job security for 'dead' languages. </p>
<p>Looks like Silverlight has seen nothing but positive growth over the past few years. Was it two years ago Microsoft and .NET developers where predicting the death of Flash due to Silverlight? Looks like there is enough market for both. If the web wants interactive maybe there is room for Flash, HTML5, and Silverlight to all grow over the next 5 years. Based on the data at hand, that would be my prediction.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2010/02/01/cut-the-drama-flash-is-here-to-stay/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Compress Transparent PNGs with Flash</title>
		<link>http://www.blackcj.com/blog/2009/07/24/compress-transparent-pngs-with-flash/</link>
		<comments>http://www.blackcj.com/blog/2009/07/24/compress-transparent-pngs-with-flash/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 14:52:48 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Compression]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[Myth]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=465</guid>
		<description><![CDATA[Do you use transparent PNGs in Flash, Flex or AIR? Want to cut your application file size in half? Problem: Embedding transparent PNGs dramatically increases the size of your Flash, Flex and AIR applications. Photoshop and Fireworks dot not have any compression available for transparent PNGs (that I am aware of). Solution: Import your PNGs [...]]]></description>
			<content:encoded><![CDATA[<p>Do you use transparent PNGs in Flash, Flex or AIR?  Want to cut your application file size in half?</p>
<p><strong>Problem:</strong><br />
Embedding transparent PNGs dramatically increases the size of your Flash, Flex and AIR applications.  Photoshop and Fireworks dot not have any compression available for <strong>transparent</strong> PNGs (that I am aware of).</p>
<p><strong>Solution:</strong><br />
Import your PNGs into Flash, give them a linkage id, and export the file as a SWF.  Make sure to set your compression level in the publish settings (default is 80%).  Using this method, I was able to cut the file size <strong>in half</strong> for a number of applications.</p>
<div class="igBar"><span id="lactionscript-9"><a href="#" onclick="javascript:showPlainTxt('actionscript-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-9">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">"/assets/images/images.swf#myImage"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> MyImage:<span style="color: #000000; font-weight: bold;">Class</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> myImage:Sprite = <span style="color: #000000; font-weight: bold;">new</span> MyImage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as Sprite; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>rather than...</p>
<div class="igBar"><span id="lactionscript-10"><a href="#" onclick="javascript:showPlainTxt('actionscript-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-10">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Don't use this one <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">"/assets/images/myImage.png"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> MyImage:<span style="color: #000000; font-weight: bold;">Class</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> myImage:BitmapAsset = <span style="color: #000000; font-weight: bold;">new</span> MyImage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as BitmapAsset; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>It is also much easier to manage your external assets from a SWF.  Designers can set up a nice slice sheet using the stage in Flash.  Much easier than managing tons of small PNGs in folders everywhere.</p>
<h3>Image Manager</h3>
<p>In addition to using the SWF it can also be very useful to set up an ImageManager to serve out images to your application.  This prevents having to change code in multiple places to update the same image reference.</p>
<p>Image Manager Class:</p>
<div class="igBar"><span id="lactionscript-11"><a href="#" onclick="javascript:showPlainTxt('actionscript-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-11">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">cb</span>.<span style="color: #006600;">utils</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ImageManager</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const MY_IMAGE_ID:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"my_image_id"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span>source=<span style="color: #ff0000;">"/assets/images/images.swf#myImage"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">var</span> MyImage:<span style="color: #000000; font-weight: bold;">Class</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> getMovie<span style="color: #66cc66;">&#40;</span>id:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:Sprite</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> result:Sprite;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> MY_IMAGE_ID:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">default</span>:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = <span style="color: #000000; font-weight: bold;">new</span> MyImage<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> result;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>To access an image from the manager class just make this call:</p>
<div class="igBar"><span id="lactionscript-12"><a href="#" onclick="javascript:showPlainTxt('actionscript-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-12">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> myImage:BitmapAsset = ImageManager.<span style="color: #006600;">getImage</span><span style="color: #66cc66;">&#40;</span>ImageManager.<span style="color: #006600;">MY_IMAGE_ID</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h3>Importing PNGs into Flash</h3>
<p>And for those of you that need a refresher on importing PNGs into Flash and setting up linkage IDs:</p>
<div id="attachment_468" class="wp-caption alignnone" style="width: 443px"><img class="size-full wp-image-468" title="Step 1" src="http://www.blackcj.com/blog/wp-content/uploads/2009/07/step1.jpg" alt="File-&gt;Import-&gt;Import to Stage..." width="433" height="374" /><p class="wp-caption-text">File-&gt;Import-&gt;Import to Stage...</p></div>
<p>Right click on the image. Select 'Convert to Symbol'...</p>
<p><img src="http://www.blackcj.com/blog/wp-content/uploads/2009/07/step2.png" alt="Step 2" title="Step 2" width="345" height="396" class="alignnone size-full wp-image-546" /></p>
<p>Finally...</p>
<p><img src="http://www.blackcj.com/blog/wp-content/uploads/2009/07/step3.png" alt="Step 3" title="Step 3" width="433" height="540" class="alignnone size-full wp-image-545" /></p>
<p>Enjoy!</p>
<p><em>Disclaimer: It may be obvious but you must be using transparent PNGs in your app to see a decrease in file size <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   Most of the apps I work on have lots of transparent PNGs!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2009/07/24/compress-transparent-pngs-with-flash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Registration Open for MN.swf Camp 2009</title>
		<link>http://www.blackcj.com/blog/2009/03/05/mnswf-camp-2009/</link>
		<comments>http://www.blackcj.com/blog/2009/03/05/mnswf-camp-2009/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 22:15:44 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[MN.swf]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=257</guid>
		<description><![CDATA[Who Should Attend? Anyone interested in Flash, Flex, ActionScript or Adobe AIR. What is MN.swf Camp? A one-day event focused on connecting the local developer community and providing education on Flash Platform technologies. All for only $40! When is it? Monday, April 6, 2009 from 9:00am - 5:00pm How do I register? Go to http://mnswf.com/camp/ [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_260" class="wp-caption alignnone" style="width: 485px"><a href="http://mnswf.com/camp/"><img src="http://www.blackcj.com/blog/wp-content/uploads/2009/03/mnswfcamplogo.jpg" alt="MN.swf Camp presented by Flashbelt" title="MN.swf Camp" width="475" height="100" class="size-full wp-image-260" /></a><p class="wp-caption-text">MN.swf Camp presented by Flashbelt</p></div>
<p><strong>Who Should Attend?</strong><br />
Anyone interested in Flash, Flex, ActionScript or Adobe AIR.</p>
<p><strong>What is MN.swf Camp?</strong><br />
A one-day event focused on connecting the local developer community and providing education on Flash Platform technologies.  All for only $40!</p>
<p><strong>When is it?</strong><br />
Monday, April 6, 2009 from 9:00am - 5:00pm</p>
<p><strong>How do I register?</strong><br />
Go to <a href="http://mnswf.com/camp/">http://mnswf.com/camp/</a> and register today!</p>
<p><strong>Where will it be?</strong><br />
Minneapolis Central Library, 300 Nicollet Mall, Minneapolis, MN 55401 (<a href="http://maps.google.com/maps?f=q&#038;source=s_q&#038;hl=en&#038;geocode=&#038;q=300+Nicollet+Mall,+Minneapolis,+MN+55401&#038;sll=44.980684,-93.268567&#038;sspn=0.002592,0.004828&#038;ie=UTF8&#038;ll=44.981724,-93.268465&#038;spn=0.005001,0.009656&#038;z=17&#038;iwloc=addr">Google Maps</a>)</p>
<p><strong>Speakers:</strong><br />
Jason Grey, Brad Bollinger, Chris Black, Nate Pacyga, Danny Patterson, Scott Langeberg, Wade Arnold, Jonathan Doklovic and Dustin Tauer</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2009/03/05/mnswf-camp-2009/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flashbelt 2009 Tickets</title>
		<link>http://www.blackcj.com/blog/2009/01/13/flashbelt-2009-tickets/</link>
		<comments>http://www.blackcj.com/blog/2009/01/13/flashbelt-2009-tickets/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 17:37:33 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flashbelt]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=176</guid>
		<description><![CDATA[The first 100 Flashbelt Tickets are going for a sale price of $279. Flashbelt is a yearly conference held in Minneapolis, Minnesota and focuses on RIA development. Confirmed speakers include: James Patterson (presstube), Hoss Gifford, Mario Klingemann (quasimondo), Joa Ebert, Seb Lee-Delisle (plug-in media), Drew Trujillo (dr. woohoo), Lisa Larson-Kelley, Geoff Stearns (youtube), Jeremy Thorp [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flashbelt.com/"><img class="size-full wp-image-182" title="Flashbelt 2009" src="http://www.blackcj.com/blog/wp-content/uploads/2009/01/flashbelt09banner468x600.jpg" alt="" width="468" height="60" /></a></p>
<p>The first 100 <a href="http://pilotvibe.list-manage.com/track/click?u=bbe6fe5d4f86036a504fa5b92&amp;id=bb1950780f&amp;e=227a8fbcbc">Flashbelt Tickets</a> are going for a sale price of $279. </p>
<p>Flashbelt is a yearly conference held in Minneapolis, Minnesota and focuses on RIA development.</p>
<p>Confirmed speakers include:<br />
James Patterson (presstube), Hoss Gifford, Mario Klingemann (quasimondo),<br />
Joa Ebert,  Seb Lee-Delisle (plug-in media), Drew Trujillo (dr. woohoo),<br />
Lisa Larson-Kelley, Geoff Stearns (youtube),  Jeremy Thorp (blprnt.com),<br />
Koen DeWeggheleire, Veronique Brossier (v-ro.com),  Stacey Mulcahey, Julian<br />
Dolce (fuel industries), Robert Reinhardt, Rich Shupe, Niqui Merret, and<br />
Andre Michelle...with more on the way.</p>
<p>For more information about Flashbelt check out the webpage: <a href="http://www.flashbelt.com/#/about/">Flashbelt</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2009/01/13/flashbelt-2009-tickets/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PSDTemple: Turn Your PSD&#8217;s into xHTML</title>
		<link>http://www.blackcj.com/blog/2008/12/01/psdtemple-turn-your-psds-into-xhtml/</link>
		<comments>http://www.blackcj.com/blog/2008/12/01/psdtemple-turn-your-psds-into-xhtml/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 02:55:20 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[PSD]]></category>
		<category><![CDATA[PSDTemple]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=122</guid>
		<description><![CDATA[This is an ActionScript blog, however, I'm going to show my support for a very good friend of mine (and very successful entrepreneur) who has started: PSDTemple. A service that allows designers to turn their PSDs into functional user interfaces. Great price and great service deserves a bit of attention Thank you for understanding the [...]]]></description>
			<content:encoded><![CDATA[<p>This is an ActionScript blog, however, I'm going to show my support for a very good friend of mine (and very successful entrepreneur) who has started: PSDTemple.  A service that allows designers to turn their PSDs into functional user interfaces.  Great price and great service deserves a bit of attention <img src='http://www.blackcj.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Thank you for understanding the off topic post.  If all goes well PSDTemple will soon be creating Flash websites as well.  Which would definitely make my day!</p>
<p><a href="http://www.psdtemple.com/">http://www.psdtemple.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2008/12/01/psdtemple-turn-your-psds-into-xhtml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FlexFeed: Twitter RSS Feeds in Flex</title>
		<link>http://www.blackcj.com/blog/2008/10/04/flexfeed-integrate-twitter-rss-feeds-into-flex/</link>
		<comments>http://www.blackcj.com/blog/2008/10/04/flexfeed-integrate-twitter-rss-feeds-into-flex/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 20:29:12 +0000</pubDate>
		<dc:creator>Chris Black</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Cross Domain XML]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex Builder 3]]></category>
		<category><![CDATA[HTTPService]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.blackcj.com/blog/?p=3</guid>
		<description><![CDATA[Using Flex and PHP it is possible to integrate Twitter RSS feeds into a Flex web page. Twitters cross domain policy (which is used by Flash) does not allow external resources to access feeds. Using PHP as a medium to the data, Flex can access the feed and display all contents. This technique can be [...]]]></description>
			<content:encoded><![CDATA[<p>Using Flex and PHP it is possible to integrate Twitter RSS feeds into a Flex web page.  Twitters cross domain policy (which is used by Flash) does not allow external resources to access feeds.  Using PHP as a medium to the data, Flex can access the feed and display all contents.  This technique can be used to access any xml data that Flex may not have access to.</p>
<p>Let's start by creating an HTTPService:</p>
<div class="igBar"><span id="lhtml-18"><a href="#" onclick="javascript:showPlainTxt('html-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-18">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;">&lt;mx:HTTPService </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"rssParse"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; url=<span style="color: #ff0000;">"http://twitter.com/statuses/user_timeline/16584421.rss"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; result=<span style="color: #ff0000;">"processResult(event)"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; resultFormat=<span style="color: #ff0000;">"e4x"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Next we will create the function to process the results:</p>
<div class="igBar"><span id="lactionscript-19"><a href="#" onclick="javascript:showPlainTxt('actionscript-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-19">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">collections</span>.<span style="color: #006600;">ArrayCollection</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">rpc</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">ResultEvent</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _rssResults:ArrayCollection;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Define and use atom namespace.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> namespace atom = <span style="color: #ff0000;">"http://www.w3.org/2005/Atom"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">use namespace atom;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> processResult<span style="color: #66cc66;">&#40;</span>event:ResultEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> xmlList:XMLList = event.<span style="color: #006600;">result</span>.<span style="color: #006600;">channel</span>.<span style="color: #006600;">item</span> as XMLList;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">for</span> each<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> item:<span style="color: #0066CC;">XML</span> <span style="color: #b1b100;">in</span> xmlList<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> myDate:<span style="color: #0066CC;">String</span> = item.<span style="color: #006600;">pubDate</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">myDate = myDate.<span style="color: #0066CC;">slice</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span>,<span style="color: #cc66cc;color:#800000;">22</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">_rssResults.<span style="color: #006600;">addItem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title: item.<span style="color: #006600;">title</span>, <span style="color: #0066CC;">date</span>: myDate<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">_rssResults = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">rssParse.<span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now lets add the mxml to display the content:</p>
<div class="igBar"><span id="lhtml-20"><a href="#" onclick="javascript:showPlainTxt('html-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-20">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;">&lt;mx:VBox <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"400"</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">"600"</span> horizontalAlign=<span style="color: #ff0000;">"center"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;">&lt;mx:<span style="color: #000066;">Label</span> styleName=<span style="color: #ff0000;">"subTitleText"</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">"Twitter Feed:"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> fontSize=<span style="color: #ff0000;">"16"</span>/<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;">&lt;mx:VBox <span style="color: #000066;">height</span>=<span style="color: #ff0000;">"500"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"400"</span> verticalScrollPolicy=<span style="color: #ff0000;">"auto"</span> horizontalScrollPolicy=<span style="color: #ff0000;">"off"</span> horizontalAlign=<span style="color: #ff0000;">"center"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;mx:Repeater <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"twitter"</span> dataProvider=<span style="color: #ff0000;">"{_rssResults}"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;mx:<span style="color: #000066;">Text</span> textAlign=<span style="color: #ff0000;">"center"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"300"</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">"{twitter.currentItem.date}"</span>/<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;mx:<span style="color: #000066;">Text</span> textAlign=<span style="color: #ff0000;">"center"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"300"</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">"{twitter.currentItem.title}"</span>/<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span></a>/mx:Repeater&gt;</span>&nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span></a>/mx:VBox&gt;</span>&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span></a>/mx:VBox&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>After testing the application locally everything works great!  But wait... what about the PHP code?  Well first export a release build of the application and upload it to a web server for testing.</p>
<p>Here is the error that you should recieve:<br />
<strong>[RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Destination: DefaultHTTP"]</strong></p>
<p>To get around this let's create a php file that collects the twitter data:</p>
<div class="igBar"><span id="lphp-21"><a href="#" onclick="javascript:showPlainTxt('php-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-21">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$twitter_feed</span> = <span style="color:#FF0000;">'http://twitter.com/statuses/user_timeline/16584421.rss'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$rawfeed</span> = @<a href="http://www.php.net/file_get_contents"><span style="color:#000066;">file_get_contents</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$twitter_feed</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/print"><span style="color:#000066;">print</span></a> <span style="color:#0000FF;">$rawfeed</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now we need to update our HTTPService request to pull from the new php file:</p>
<div class="igBar"><span id="lhtml-22"><a href="#" onclick="javascript:showPlainTxt('html-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-22">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;">&lt;mx:HTTPService </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"rssParse"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; url=<span style="color: #ff0000;">"php/twitter.php"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; result=<span style="color: #ff0000;">"processResult(event)"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; resultFormat=<span style="color: #ff0000;">"e4x"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now everything works great!</p>
<p>Check out this link to view a functional example:<br />
<a href="http://www.blackcj.com/FlexFeed/index.html">http://www.blackcj.com/FlexFeed/index.html</a></p>
<p>And the source files:<br />
<a href="http://www.blackcj.com/FlexFeed/srcview/index.html">http://www.blackcj.com/FlexFeed/srcview/index.html</a></p>
<p>Please leave a comment if you have any questions, comments, or suggestions.  Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blackcj.com/blog/2008/10/04/flexfeed-integrate-twitter-rss-feeds-into-flex/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.789 seconds -->

