<?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>Bagonca &#187; cacheAsBitmap</title>
	<atom:link href="http://www.bagonca.com/blog/tag/cacheasbitmap/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bagonca.com/blog</link>
	<description>Yet another developer blog</description>
	<lastBuildDate>Fri, 18 Jun 2010 09:28:59 +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>Use cacheAsBitmap correctly &#8211; or not at all</title>
		<link>http://www.bagonca.com/blog/2009/04/17/use-cacheasbitmap-correctly-or-not-at-all/</link>
		<comments>http://www.bagonca.com/blog/2009/04/17/use-cacheasbitmap-correctly-or-not-at-all/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 15:03:37 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Flex/AS]]></category>
		<category><![CDATA[cacheAsBitmap]]></category>
		<category><![CDATA[Flex and ActionScript]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=155</guid>
		<description><![CDATA[Learn what problems cacheAsBitmap can cause and when it is correct to use it = nearly never.]]></description>
			<content:encoded><![CDATA[<p>You may have heard that the <code>cacheAsBitmap</code> functionality introduced in FlashPlayer 8 and available since Flex SDK 3 can sometimes help you improve performance. That is true, but only as long as the disply object is <strong>only moved</strong>.</p>
<ul>
<li>If you apply any other transformation on the display object, FlashPlayer will cache a new rasterised version of the object for each iteration of the transformation.</li>
<li>If you apply any filters to your object, two versions are cached, one &#8220;normal&#8221; and one for the filtered result.</li>
</ul>
<p>Both of these things may result in a higher than necessary load on your CPU and memory resources, <strong>when doing anything but only moving the display object</strong>.</p>
<p>Therefore, use <code>cacheAsBitmap</code> only on display objects that you know will only be moved around the stage, never on objects that will have any other sort of transformation.</p>
<p>An added problem with <code>cacheAsBitmap</code> is a known &#8220;bug&#8221; in the Mac version of the FlashPlayer where display objects that are using it can misunderstand their own redraw regions, resulting in a corrupted view. It seems rather rare though.</p>
<p>Also, when extending UIComponents &#8211; the default FlashPlayer behaviour is to heuristically try to find out if you usually <code>cacheAsBitmap</code>. If you look at the code in UIComponent of Flex 3 SDK you will find the following statement:</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: #6699cc; font-weight: bold;">var</span> _cachePolicy<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = UIComponentCachePolicy.<span style="color: #004993;">AUTO</span>;</pre></div></div>

<p>To make sure that the default behaviour of all of your objects that inherit from UIComponent instead inherit from your own extension of UIComponent which could invoke</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">this</span>.setCachePolity = UIComponentCachePolicy.OFF</pre></div></div>

<p>There are many people out there who have opinions about the <code>cacheAsBitmap</code> functionality as it is implemented today. Two examples are:</p>
<ul>
<li><a title="by Actionscript guru Thibault Imbert " href="http://www.bytearray.org/?p=290" target="_self">Why cacheAsBitmap is bad</a></li>
<li><a title="by Actionscript guru Thibault Imbert " href="http://www.bytearray.org/?p=403">Vote for a new cacheAsBitmap behavior!</a></li>
<li><a title="by Jesse Warden" href="http://jessewarden.com/2008/11/flex-move-effect-messes-up-mask-alignment.html">Flex Move Effect Messes Up Mask Alignment</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2009/04/17/use-cacheasbitmap-correctly-or-not-at-all/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
