<?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:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Miscellanea</title>
	<atom:link href="http://userflex.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://userflex.wordpress.com</link>
	<description>Tasty tidbits of Flex knowledge</description>
	<pubDate>Wed, 20 Aug 2008 20:54:23 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Adding Channel Definition Timeouts</title>
		<link>http://userflex.wordpress.com/2008/08/20/channel-timeouts/</link>
		<comments>http://userflex.wordpress.com/2008/08/20/channel-timeouts/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 20:52:13 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
		
		<category><![CDATA[ActionScript]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://userflex.wordpress.com/?p=160</guid>
		<description><![CDATA[Following up my post last week on creating channel definitions, I realize I forgot to add one key piece of code - timeouts!
Why are these important?
For starters, the connection timeout prevents you from waiting until the end of time to get a response from the remote destination. Since you typically connect when your application first [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Following up my <a href="http://userflex.wordpress.com/2008/08/12/fds-channels-in-as3/" target="_blank">post</a> last week on creating channel definitions, I realize I forgot to add one key piece of code - timeouts!</p>
<p>Why are these important?</p>
<p>For starters, the connection timeout prevents you from waiting until the end of time to get a response from the remote destination. Since you typically connect when your application first loads, this can result in an unnaturally long startup time when the remote destination is slow or unavailable.</p>
<p>Not having a connection timeout also causes failover (e.g. from RTMP to polling) to take a <em>really</em> long time.</p>
<p>Similarly, the request timeout helps prevent your application from appearing unresponsive. Better to handle slow asychronous calls with progress indicators rather than simply hope they&#8217;ll return in a reasonable amount of time.</p>
<p>So without further ado, here are the lines to add to your channel definitions for connection and request timeouts:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
// sets the connection and request timeouts<br />
var connectTimeoutInSec : Number = 3;<br />
var requestTimeoutInSec : Number = 10;<br />
<br />
rtmpChannel.connectTimeout = connectTimeoutInSec;<br />
rtmpChannel.requestTimeout = requestTimeoutInSec;<br />
<br />
pollingChannel.connectTimeout = connectTimeoutInSec;<br />
pollingChannel.requestTimeout = requestTimeoutInSec;
</td>
</tr>
</table>
</div>
<p><span><br /></span>The actual values are arbitrary, so you should adjust them as needed.</p>
<p><strong>Original post:</strong> <a href="http://userflex.wordpress.com/2008/08/12/fds-channels-in-as3/">Creating FDS Channel Definitions in AS3</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/userflex.wordpress.com/160/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/userflex.wordpress.com/160/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/userflex.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/userflex.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/userflex.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/userflex.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/userflex.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/userflex.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/userflex.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/userflex.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/userflex.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/userflex.wordpress.com/160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&blog=2607426&post=160&subd=userflex&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://userflex.wordpress.com/2008/08/20/channel-timeouts/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/userflex-128.jpg" medium="image">
			<media:title type="html">Nick</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating FDS Channel Definitions in AS3</title>
		<link>http://userflex.wordpress.com/2008/08/12/fds-channels-in-as3/</link>
		<comments>http://userflex.wordpress.com/2008/08/12/fds-channels-in-as3/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 18:32:12 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
		
		<category><![CDATA[ActionScript]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://userflex.wordpress.com/?p=116</guid>
		<description><![CDATA[Anyone familiar with Flex Data Services knows about services-config.xml.
This file usually contains security constraint definitions, channel definitions, and logging settings that each of the services can use. (more here)
It&#8217;s one of those config files that always feels more complicated than it needs to be, and to top it off, it&#8217;s a compile-time resource. This limits [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Anyone familiar with Flex Data Services knows about services-config.xml.</p>
<p>This file usually contains security constraint definitions, channel definitions, and logging settings that each of the services can use. (<a href="http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&amp;file=ent_services_config_097_02.html" target="_blank">more here</a>)</p>
<p>It&#8217;s one of those config files that always feels more complicated than it needs to be, and to top it off, it&#8217;s a compile-time resource. This limits its flexibility, especially when it comes to channel definitions.</p>
<p>Why should you have to recompile your application whenever your channel definitions change? Let&#8217;s declare them in AS3 instead!</p>
<p>Here&#8217;s an example of two channel definitions from a services-config.xml file:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
&lt;channel-definition id=&#8221;cf-polling-amf&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;class=&#8221;mx.messaging.channels.AMFChannel&#8221;&gt;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;endpoint uri=&#8221;http://{server.name}:80/flex2gateway/cfamfpolling&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class=&#8221;flex.messaging.endpoints.AMFEndpoint&#8221;/&gt;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;properties&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;polling-enabled&gt;true&lt;/polling-enabled&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;polling-interval-seconds&gt;2&lt;/polling-interval-seconds&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/properties&gt;<br />
<br />
&lt;/channel-definition&gt;<br />
<br />
&lt;channel-definition id=&#8221;cf-rtmp&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;class=&#8221;mx.messaging.channels.RTMPChannel&#8221;&gt;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;endpoint uri=&#8221;rtmp://{server.name}:2048&#8243;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class=&#8221;flex.messaging.endpoints.RTMPEndpoint&#8221;/&gt;<br />
<br />
&lt;/channel-definition&gt;
</td>
</tr>
</table>
</div>
<p><span><br /></span>Now let&#8217;s look at the same two channel definitions in AS3:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
var serverName : String = parameters.serverName;<br />
<br />
var pollingChannel : AMFChannel = new AMFChannel (&#8221;cf-polling-amf&#8221;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#8221;http://&#8221; + serverName + &#8220;:80/flex2gateway/cfamfpolling&#8221;);<br />
var rtmpChannel : RTMPChannel = new RTMPChannel (&#8221;cf-rtmp&#8221;,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#8221;rtmp://&#8221; + serverName + &#8220;:2048&#8243;);<br />
<br />
pollingChannel.pollingEnabled = true;<br />
pollingChannel.pollingInterval = 2000;<br />
<br />
var channelSet : ChannelSet = new ChannelSet ();<br />
channelSet.addChannel (pollingChannel);<br />
channelSet.addChannel (rtmpChannel);
</td>
</tr>
</table>
</div>
<p><span><br /></span>At first glance this code doesn&#8217;t appear to offer any advantage over the channels defined in services-config.xml. However in the AS3 code, the server name for the channels is passed in as a flashVar to the application.</p>
<p>This allows your application to determine at runtime which channels to use, and it also eliminates the need to compile the XML file into your application.</p>
<p>Two wins in my book.</p>
<p><strong>Addendum:</strong> <a href="http://userflex.wordpress.com/2008/08/20/channel-timeouts/">Adding Channel Definition Timeouts</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/userflex.wordpress.com/116/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/userflex.wordpress.com/116/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/userflex.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/userflex.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/userflex.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/userflex.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/userflex.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/userflex.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/userflex.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/userflex.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/userflex.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/userflex.wordpress.com/116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&blog=2607426&post=116&subd=userflex&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://userflex.wordpress.com/2008/08/12/fds-channels-in-as3/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/userflex-128.jpg" medium="image">
			<media:title type="html">Nick</media:title>
		</media:content>
	</item>
		<item>
		<title>Using LiveCycle Data Services with Custom Components</title>
		<link>http://userflex.wordpress.com/2008/08/01/lcds-with-custom-components/</link>
		<comments>http://userflex.wordpress.com/2008/08/01/lcds-with-custom-components/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 00:38:26 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
		
		<category><![CDATA[ActionScript]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[LCDS]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://userflex.wordpress.com/?p=75</guid>
		<description><![CDATA[LiveCycle Data Services. I&#8217;ve mentioned it before.
It can be an indispensable tool. But like any good black box, getting it to work properly is a huge pain in the ass.
One of the biggest benefits of LCDS is paging. Paging lets you dynamically load data as soon as it&#8217;s accessed within a collection. This is great [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>LiveCycle Data Services. I&#8217;ve <a href="http://userflex.wordpress.com/2008/05/01/managed-sorts-and-filters/">mentioned</a> it before.</p>
<p>It can be an indispensable tool. But like any good black box, getting it to work properly is a huge pain in the ass.</p>
<p>One of the biggest benefits of LCDS is paging. Paging lets you dynamically load data as soon as it&#8217;s accessed within a collection. This is great for large data sets, and the beauty of this approach is that you don&#8217;t have to do anything special for it to work.</p>
<p>Create a collection, bind it to your view, and connect it to a data service. As you interact with the view, LCDS will automatically retrieve the data in the background.</p>
<p>Beautiful, right?</p>
<p>But let&#8217;s say you want to use a custom component instead of a standard <code>List</code> or <code>DataGrid</code> to display your data. This is where the magic breaks down.</p>
<p>You see, LCSD only works &#8220;as advertised&#8221; when you use built-in components. Any Flex component that can accept an <code>ICollectionView</code> as a <code>dataProvider</code> has specific logic to handling paging.</p>
<p>This is because paging is just a series of asynchronous remoting calls performed behind the scenes. When a component tries to access data that isn&#8217;t available, an <code>ItemPendingError</code> is thrown and a remoting call is made to retrieve it.</p>
<p>Since there&#8217;s nothing to access right away, the component will substitute a placeholder in lieu of the actual data. When the remoting call returns, the component will then swap out the placeholder for the data.</p>
<p>This is all fine and good, even though it does reveal somewhat how the sausage is being made. You just don&#8217;t get any of this for free if you use your own custom component.</p>
<p>However this doesn&#8217;t mean it&#8217;s impossible. You just have to support the asynchronous method in which the data is accessed - something I&#8217;ll detail in a future post.</p>
<p>(cliffhanger)  <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/userflex.wordpress.com/75/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/userflex.wordpress.com/75/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/userflex.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/userflex.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/userflex.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/userflex.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/userflex.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/userflex.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/userflex.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/userflex.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/userflex.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/userflex.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&blog=2607426&post=75&subd=userflex&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://userflex.wordpress.com/2008/08/01/lcds-with-custom-components/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/userflex-128.jpg" medium="image">
			<media:title type="html">Nick</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Cache Images in Your Flex Application</title>
		<link>http://userflex.wordpress.com/2008/07/28/image-caching/</link>
		<comments>http://userflex.wordpress.com/2008/07/28/image-caching/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 17:05:40 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
		
		<category><![CDATA[ActionScript]]></category>

		<category><![CDATA[Flex]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://userflex.wordpress.com/?p=51</guid>
		<description><![CDATA[Caching images in your Flex application can greatly improve performance and reduce the overhead of loading external resources.
And I&#8217;m not simply talking about using the cacheAsBitmap property to improve rendering performance or the cachePolicy property to speed up animations. I&#8217;m talking about caching the actual bitmap data of an image.
To get started, you&#8217;ll need a [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Caching images in your Flex application can greatly improve performance and reduce the overhead of loading external resources.</p>
<p>And I&#8217;m not simply talking about using the <code>cacheAsBitmap</code> property to improve rendering performance or the <code>cachePolicy</code> property to speed up animations. I&#8217;m talking about caching the actual bitmap data of an image.</p>
<p>To get started, you&#8217;ll need a hash map to store the image data. A <code>Dictionary</code> or an associative array will also work just fine.</p>
<p>Loading an image for the first time is the same as usual. You create a new <code>Image</code> object and add a listener for the <code>COMPLETE</code> event:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
var image : Image = new Image ();<br />
image.addEventListener (Event.COMPLETE, onImageComplete);
</td>
</tr>
</table>
</div>
<p><span><br /></span>Once the image has finished loading, you add a copy of the bitmap data to the hash map using the image URL as the hash key:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
private function onImageComplete (event : Event) : void<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;var image : Image = event.target as Image;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;if (! imageCache.containsKey (image.source))<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var bitmapData : BitmapData = new BitmapData<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(image.content.width, image.content.height, true);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bitmapData.draw (image.content);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;imageCache.put (image.source, bitmapData);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}
</td>
</tr>
</table>
</div>
<p><span><br /></span>Now we can use the image as many times as we want without ever having to load it again!</p>
<p>To take advantage of this, you&#8217;ll need to check the hash map every time you create a new image (or change the <code>source</code> property) to see if you&#8217;ve already cached it:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
var image : Image = new Image ();<br />
image.addEventListener (Event.COMPLETE, onImageComplete);<br />
<br />
if (imageCache.containsKey (imageURL))<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;image.source = new Bitmap (imageCache.getValue (imageURL));<br />
}<br />
else<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;image.source = imageURL;<br />
}
</td>
</tr>
</table>
</div>
<p><span><br /></span>And that&#8217;s it!</p>
<p>If you have an application that loads a large number of images you may want to limit the number of cached images to prevent the Flash player memory usage from getting out of hand, but in general caching even several dozen large images only results in a slightly increased footprint.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/userflex.wordpress.com/51/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/userflex.wordpress.com/51/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/userflex.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/userflex.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/userflex.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/userflex.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/userflex.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/userflex.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/userflex.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/userflex.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/userflex.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/userflex.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&blog=2607426&post=51&subd=userflex&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://userflex.wordpress.com/2008/07/28/image-caching/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/userflex-128.jpg" medium="image">
			<media:title type="html">Nick</media:title>
		</media:content>
	</item>
		<item>
		<title>Track Memory Usage in Your Flex Application</title>
		<link>http://userflex.wordpress.com/2008/07/18/track-mem-usage/</link>
		<comments>http://userflex.wordpress.com/2008/07/18/track-mem-usage/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 19:23:16 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://userflex.wordpress.com/?p=44</guid>
		<description><![CDATA[A simple way to track memory usage in your Flex application is to create a Label that displays the System.totalMemory property and updates it on render events.
This isn&#8217;t anything fancy, but it&#8217;s useful when checking for memory leaks and helps you avoid making mistakes when dealing with memory intensive applications.
Also, its just kind of cool. [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A simple way to track memory usage in your Flex application is to create a <code>Label</code> that displays the <code>System.totalMemory</code> property and updates it on render events.</p>
<p>This isn&#8217;t anything fancy, but it&#8217;s useful when checking for memory leaks and helps you avoid making mistakes when dealing with memory intensive applications.</p>
<p>Also, its just kind of cool.  <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_cool.gif' alt='8-)' class='wp-smiley' /> </p>
<p>You can even go a step further and create a button that allows you to manually perform garbage collection. This, coupled with the memory monitor, gives you the basic workings of a Flash Player memory management tool.</p>
<p>Just remember that <code>System.totalMemory</code> reports the total memory in use across ALL instances of Flash Player and not just the current one - so if you have other Flash or Flex applications open your usage patterns will be skewed!</p>
<p>Here&#8217;s some sample code for the label and button:</p>
<div style="font-family:courier;border:1px solid #9c9c9c;background-color:#f3f3f3;">
<table>
<tr>
<td>
&lt;mx:Label id=&#8221;totalMemory&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;text=&#8221;{(System.totalMemory / 1024) + &#8216; KB&#8217;}&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;render=&#8221;totalMemory.text = (System.totalMemory / 1024) + &#8216; KB&#8217;&#8221; /&gt;<br />
<br />
&lt;mx:Button id=&#8221;gcButton&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;label=&#8221;force garbage collection&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;click=&#8221;System.gc ()&#8221; /&gt;
</td>
</tr>
</table>
</div>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/userflex.wordpress.com/44/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/userflex.wordpress.com/44/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/userflex.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/userflex.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/userflex.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/userflex.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/userflex.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/userflex.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/userflex.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/userflex.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/userflex.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/userflex.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=userflex.wordpress.com&blog=2607426&post=44&subd=userflex&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://userflex.wordpress.com/2008/07/18/track-mem-usage/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/userflex-128.jpg" medium="image">
			<media:title type="html">Nick</media:title>
		</media:content>
	</item>
	</channel>
</rss>