<?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>distortion &#187; external</title>
	<atom:link href="http://www.giordanopiazza.com/blog/tag/external/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.giordanopiazza.com/blog</link>
	<description>gyo goes blogging</description>
	<lastBuildDate>Sun, 20 Jun 2010 11:05:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Allow smoothing for external images (as2)</title>
		<link>http://www.giordanopiazza.com/blog/flash/allow-smoothing-for-external-images-as2/</link>
		<comments>http://www.giordanopiazza.com/blog/flash/allow-smoothing-for-external-images-as2/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 14:09:10 +0000</pubDate>
		<dc:creator>gyo</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as2]]></category>
		<category><![CDATA[external]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[smoothing]]></category>

		<guid isPermaLink="false">http://www.giordanopiazza.com/blog/?p=110</guid>
		<description><![CDATA[Here is a simple function to set the "Allow smoothing" images property at run-time in Flash. Let's say you have a blank MovieClip named target_mc and you load an external image, it will be rendered without anti-alias/smoothing; I needed it to be smooth for a full-browser background story and the support for transparent images was [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a simple function to set the "Allow smoothing" images property at run-time in Flash.<br />
Let's say you have a blank MovieClip named <strong>target_mc</strong> and you load an external image, it will be rendered without anti-alias/smoothing; I needed it to be smooth for a full-browser background story and the support for transparent images was a must, so here we go:</p>
<p><code lang="actionscript"><br />
function smooth(mc:MovieClip)<br />
{<br />
var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true, 0x000000);<br />
mc.attachBitmap(bitmap, 0, "auto", true);<br />
bitmap.draw(mc);<br />
}<br />
</code></p>
<p>To use it, just call the function pointing to the target mc:<br />
<code lang="actionscript"><br />
smooth(target_mc);<br />
</code></p>
<p>As you can see from the code, the function doesn't load anything, it just re-draws a MovieClip with the "Allow smoothing" property set; this is because I needed a quick and simple function to render any MovieClip, since I use another library to handle the loading process.</p>
<p>Note: The code is actionscript2. I didn't investigate the actionscript3 behavior about this issue, if you know something please drop a comment!</p>
<p><strong><span style="color: #ff0000;">IMPORTANT UPDATE</span></strong><br />
I tried what <strong>Non Cho</strong> suggested and it works for Flash Player 8! Thanks man!<br />
You no longer need the <strong>smooth()</strong> function, just keep it in case you need to export for Flash Player 7.<br />
All you have to do is to apply the <strong>forceSmoothing</strong> property to a MovieClip after the content (image or whatever) has finished loading:</p>
<p><code lang="actionscript"><br />
mc.forceSmoothing = true;<br />
</code></p>
<p><strong>Remember</strong> to set the <strong>forceSmoothing</strong> property to <strong>true</strong> only AFTER the content of the MovieClip has been completely loaded. This is very important, otherwise it will not work.</p>
<p>One more example could be:</p>
<p><code lang="actionscript">mc.loadMovie("my_picture.jpg");</code></p>
<p><code lang="actionscript">mc.onLoad = function()<br />
{<br />
this.forceSmoothing = true;<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.giordanopiazza.com/blog/flash/allow-smoothing-for-external-images-as2/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

