<?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>Randomize Everything &#187; Flash</title>
	<atom:link href="http://www.bartclaessens.com/category/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bartclaessens.com</link>
	<description>And create the perfect world</description>
	<lastBuildDate>Sat, 17 Jul 2010 11:57:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Quicktip #6: Fixing the cut off character on embedded-font-textfields</title>
		<link>http://www.bartclaessens.com/2010/01/quicktip-6-fixing-the-cut-off-character-on-embedded-font-textfields/</link>
		<comments>http://www.bartclaessens.com/2010/01/quicktip-6-fixing-the-cut-off-character-on-embedded-font-textfields/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 21:50:42 +0000</pubDate>
		<dc:creator>Bart Claessens</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[QuickTips]]></category>
		<category><![CDATA[failing width calculation]]></category>
		<category><![CDATA[font embedding]]></category>
		<category><![CDATA[quicktip]]></category>
		<category><![CDATA[textfield autosize]]></category>

		<guid isPermaLink="false">http://www.bartclaessens.com/?p=191</guid>
		<description><![CDATA[As we all know, Flash has these crazy bugs nobody ever understands. One of those is the fact that the last character of a dynamic textfield (which has been set to &#8220;AutoSize&#8221;) gets cut off when you&#8217;re using an embedded font. Up till now I still don&#8217;t understand what kind of situation leads to this [...]]]></description>
			<content:encoded><![CDATA[<p>As we all know, Flash has these crazy bugs nobody ever understands. One of those is the fact that the last character of a dynamic textfield (which has been set to &#8220;AutoSize&#8221;) gets cut off when you&#8217;re using an embedded font. Up till now I still don&#8217;t understand what kind of situation leads to this exceptional behavior. The only thing I can say is that Flash Player fails to determine the correct text length which screws up the textfield width to be shorter than it has to be.</p>
<p>Example:<br />
<div id="attachment_193" class="wp-caption alignnone" style="width: 261px"><a href="http://www.bartclaessens.com/wp-content/uploads/2010/01/blurredchars.jpg" rel="lightbox[191]"><img src="http://www.bartclaessens.com/wp-content/uploads/2010/01/blurredchars.jpg" alt="Blurred/Cut Off Characters" title="Blurred Characters" width="251" height="53" class="size-full wp-image-193" /></a><p class="wp-caption-text">Blurred/Cut Off Characters</p></div><br />
<span id="more-191"></span><br />
<br/><br />
A quicktip post wouldn&#8217;t be a quicktip post without a solution. So, here&#8217;s one of the tricks you might give a go: increase the rightMargin property of the TextField to a small value like 1 or 2.</p>

<div class="wp_syntax"><div class="code"><pre class="as3" style="font-family:monospace;">var textFormat:TextFormat = new TextFormat();
textFormat.rightMargin = 1;
&nbsp;
textField.antiAliasType = AntiAliasType.ADVANCED;
textField.gridFitType = GridFitType.SUBPIXEL;
textField.embedFonts = true;
textField.autoSize = TextFieldAutoSize.CENTER;
textField.defaultTextFormat = textFormat;
textField.setTextFormat(textFormat);</pre></div></div>

<p>Hope this helps!</p>
<div class="shr-publisher-191"></div>]]></content:encoded>
			<wfw:commentRss>http://www.bartclaessens.com/2010/01/quicktip-6-fixing-the-cut-off-character-on-embedded-font-textfields/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Quicktip #5: int is faster than uint</title>
		<link>http://www.bartclaessens.com/2009/06/quicktip-5-int-is-faster-than-uint/</link>
		<comments>http://www.bartclaessens.com/2009/06/quicktip-5-int-is-faster-than-uint/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 08:35:59 +0000</pubDate>
		<dc:creator>Bart Claessens</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[QuickTips]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[actionscript performance]]></category>
		<category><![CDATA[int]]></category>
		<category><![CDATA[Number]]></category>
		<category><![CDATA[performance gains]]></category>
		<category><![CDATA[uint]]></category>

		<guid isPermaLink="false">http://www.bartclaessens.com/?p=177</guid>
		<description><![CDATA[The past few weeks I&#8217;ve been programming a scheduling component in Flash which has to be extremely performant. Every small adaption in my code that could help with limiting the processing needs is a good adaption. Today I stumbled upon a post of Grant Skinner in which he explains that using a uint is slower [...]]]></description>
			<content:encoded><![CDATA[<p>The past few weeks I&#8217;ve been programming a scheduling component in Flash which has to be extremely performant. Every small adaption in my code that could help with limiting the processing needs is a good adaption. Today I stumbled upon a post of Grant Skinner in which he explains that using a uint is slower than a normal int. The uint&#8217;s can get five times slower than using a normal int.</p>
<p><span id="more-177"></span></p>
<p>So, what about the Number type? Well, I thought the Number type was a very slow type compared to the new int and uint but that also didn&#8217;t seem to be right!</p>
<blockquote><p>
Sho just posted a really interested article on why he won&#8217;t be using the int data type very frequently in ActionScript 3. Up until reading it, I had believed that as in other languages, there were large performance benefits to using ints and uints appropriately in AS3. Turns out that isn&#8217;t the case.</p>
<p>I did some quick testing on this, which confirm Sho&#8217;s assertion that int is only slightly faster than Number in ideal circumstances, but the results from uint were much more surprising.
</p></blockquote>
<p>Read the complete post here: <a href="http://www.gskinner.com/blog/archives/2006/06/types_in_as3_in.html">gskinner.com</a></p>
<div class="shr-publisher-177"></div>]]></content:encoded>
			<wfw:commentRss>http://www.bartclaessens.com/2009/06/quicktip-5-int-is-faster-than-uint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adobe Certified Flash CS3 Developer</title>
		<link>http://www.bartclaessens.com/2009/01/adobe-certified-developer-flash-cs3-developer/</link>
		<comments>http://www.bartclaessens.com/2009/01/adobe-certified-developer-flash-cs3-developer/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 19:26:44 +0000</pubDate>
		<dc:creator>Bart Claessens</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[CS3]]></category>
		<category><![CDATA[exam]]></category>

		<guid isPermaLink="false">http://www.bartclaessens.com/?p=112</guid>
		<description><![CDATA[In times of crisis there is little few work than other busy-o-noo-we-have-to-reach-our-deadline-developer-days. So, there are a few useful things we can do: invest our time into new technologies or play with things (with the technology we daily use) we didn&#8217;t play with before. Mostly because we didn&#8217;t have enough time back then. The second most [...]]]></description>
			<content:encoded><![CDATA[<p>In times of crisis there is little few work than other busy-o-noo-we-have-to-reach-our-deadline-developer-days.</p>
<p>So, there are a few useful things we can do: invest our time into new technologies or play with things (with the technology we daily use) we didn&#8217;t play with before. Mostly because we didn&#8217;t have enough time back then. The second most useful thing we can do is getting a certificate for the technologies we use every day.</p>
<p><span id="more-112"></span></p>
<p>That&#8217;s why I got myself certified for Flash CS3. The exam was made up out of 57 questions. I have to admit that the exam wasn&#8217;t a peace of cake at all, I thought it would be but some of the questions I had to answer were very complicated and about things I seldom use, like &#8216;accessibility&#8217; in Flash.<br />
I think I underestimated the exam because I have been developing Flash ActionScript 2.0 and 3.0 for about two to two and a half years. Now, this didn&#8217;t seem enough because there were a lot of questions about the Flash IDE, embedding video&#8217;s, exporting to correct formats, using the correct symbols and there specific use as Adobe intended them.</p>
<p>So, if you are considering getting a Flash CS3 certificate yourself: consider looking around for a good book with a detailed description of the complete Flash IDE and a few basics of the ActionScript Language (both ActionScript 2.0 and 3.0).</p>
<div class="shr-publisher-112"></div>]]></content:encoded>
			<wfw:commentRss>http://www.bartclaessens.com/2009/01/adobe-certified-developer-flash-cs3-developer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Code snippet: Trimming texts in AS2</title>
		<link>http://www.bartclaessens.com/2008/11/code-snippet-trimming-texts-in-as2/</link>
		<comments>http://www.bartclaessens.com/2008/11/code-snippet-trimming-texts-in-as2/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 22:22:28 +0000</pubDate>
		<dc:creator>Bart Claessens</dc:creator>
				<category><![CDATA[ActionScript 2]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[ascii]]></category>
		<category><![CDATA[carriage return]]></category>
		<category><![CDATA[newline]]></category>
		<category><![CDATA[remove characters]]></category>
		<category><![CDATA[trim]]></category>

		<guid isPermaLink="false">http://www.bartclaessens.com/?p=63</guid>
		<description><![CDATA[From time to time some of us still have to code in oldskool ActionScript 2. A few days ago a colleague asked me for a function for trimming &#8216;new line&#8217; (\n), &#8216;carriage return&#8217; (\r) characters, spaces, &#8230; So I ended up searching my archives for a code snippet to archive this functionality and look what I found: This [...]]]></description>
			<content:encoded><![CDATA[<p>From time to time some of us still have to code in oldskool ActionScript 2. A few days ago a colleague asked me for a function for trimming &#8216;new line&#8217; (\n), &#8216;carriage return&#8217; (\r) characters, spaces, &#8230;<br />
So I ended up searching my archives for a code snippet to archive this functionality and look what I found:</p>
<p><span id="more-63"></span></p>
<p>This code takes out the characters that are defined in the <code>character_array</code> variable:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// remove \r , \n , &amp;amp; from string</span>
<span style="color: #000000; font-weight: bold;">function</span> trimTextChars<span style="color: #66cc66;">&#40;</span>text_str<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> character_array:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">chr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #0066CC;">chr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #0066CC;">chr</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">38</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">var</span> inputstring:<span style="color: #0066CC;">String</span> = text_str;
    <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span> ; i <span style="color: #66cc66;">&lt;</span> character_array.<span style="color: #0066CC;">length</span> ; i++<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">var</span> temp_array = inputstring.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span>character_array<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>j=<span style="color: #cc66cc;">0</span> ; j <span style="color: #66cc66;">&lt;</span> temp_array.<span style="color: #0066CC;">length</span> ; j++<span style="color: #66cc66;">&#41;</span> temp_array<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span> = trim<span style="color: #66cc66;">&#40;</span>temp_array<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
        inputstring = temp_array.<span style="color: #0066CC;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot; &quot;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> inputstring;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>This code removes leading and trailing spaces from a given string:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Trim leading and trailing spaces from string</span>
<span style="color: #000000; font-weight: bold;">function</span> trim<span style="color: #66cc66;">&#40;</span>txt_str<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>txt_str.<span style="color: #0066CC;">charAt</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">&quot; &quot;</span><span style="color: #66cc66;">&#41;</span> txt_str = txt_str.<span style="color: #0066CC;">substring</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, txt_str.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>txt_str.<span style="color: #0066CC;">charAt</span><span style="color: #66cc66;">&#40;</span>txt_str.<span style="color: #006600;">length</span>-<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">&quot; &quot;</span><span style="color: #66cc66;">&#41;</span> txt_str = txt_str.<span style="color: #0066CC;">substring</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, txt_str.<span style="color: #006600;">length</span>-<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #b1b100;">return</span> txt_str;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Enjoy!</p>
<div class="shr-publisher-63"></div>]]></content:encoded>
			<wfw:commentRss>http://www.bartclaessens.com/2008/11/code-snippet-trimming-texts-in-as2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some ActionScript optimization tricks and good practises</title>
		<link>http://www.bartclaessens.com/2008/09/some-actionscript-optimization-tricks-and-good-practises/</link>
		<comments>http://www.bartclaessens.com/2008/09/some-actionscript-optimization-tricks-and-good-practises/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 21:46:31 +0000</pubDate>
		<dc:creator>Bart Claessens</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[actionscript performance]]></category>
		<category><![CDATA[bitmap performance]]></category>
		<category><![CDATA[bitmapdata performance]]></category>
		<category><![CDATA[destroy function]]></category>
		<category><![CDATA[large images]]></category>
		<category><![CDATA[memory management]]></category>
		<category><![CDATA[performance gains]]></category>

		<guid isPermaLink="false">http://www.bartclaessens.com/?p=30</guid>
		<description><![CDATA[The last few months I have been busy integrating Flash swf files into bigger (mostly Flex) projects. Because Flex websites might hog the memory due to large amounts of graphical elements and sometimes enormous huge amount of dynamic content, I had to keep an eye out for performance drops. There have been a lot of [...]]]></description>
			<content:encoded><![CDATA[<p>The last few months I have been busy integrating Flash swf files into bigger (mostly Flex) projects. Because Flex websites might hog the memory due to large amounts of graphical elements and sometimes enormous huge amount of dynamic content, I had to keep an eye out for performance drops.</p>
<p>There have been a lot of optimization tricks for ActionScript 3, mine listed here will probably already be somewhere on one or another guru&#8217;s blog. But I&#8217;d like to list them again because I think there is a need to educate beginning (and sometimes advanced) ActionScript developers about the different performance capabilities. Please mind that this is NOT a complete list in any way. These optimizations are the ones I had to use the most lately.</p>
<p><span id="more-30"></span></p>
<p><strong>Trick 1:</strong></p>
<p>Always create a destroy() function on your sprites/movieclips/shapes when they have a custom class applied to them or when they are just standalone custom classes.<br />
The destroy function should be responsible to do the following:</p>
<ul>
<li>clear ANY listener that was used in the custom class, use hasEventListener() to check if there is a listener added in the first place!</li>
<li>remove the children of the custom class</li>
<li>set the removed child to null to clear the reference: myChild = null;</li>
</ul>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/**
* Clean up the current circle image the gain back performance.
*/</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> cleanUpCurrentCircleImage<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
    currentCircleImage.destroy<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>currentCircleImage.<span style="color: #004993;">hasEventListener</span><span style="color: #000000;">&#40;</span>CircleImage.ANIMATED_OUT<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> currentCircleImage.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>CircleImage.ANIMATED_OUT, cleanUpCurrentCircleImage<span style="color: #000000;">&#41;</span>;
    <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>currentCircleImage.<span style="color: #004993;">hasEventListener</span><span style="color: #000000;">&#40;</span>CircleImage.ANIMATED_IN<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> currentCircleImage.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span>CircleImage.ANIMATED_IN, timeOutTillNextImage<span style="color: #000000;">&#41;</span>;
&nbsp;
    <span style="color: #004993;">removeChild</span><span style="color: #000000;">&#40;</span>currentCircleImage<span style="color: #000000;">&#41;</span>;
    currentCircleImage = <span style="color: #0033ff; font-weight: bold;">null</span>;
&nbsp;
    showImage<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>Trick 2:</strong></p>
<p>A useful trick when you have a lot of BitmapData. You have to know that a lot of BitmapData just keeps sitting in the memory although you removed the container Bitmap. Don&#8217;t ask me why the Flash Player does this but is very annoying as my colleagues at BoulevArt noticed while adding an image of 10 000 by 3000 pixels to the stage. They sliced up the image in different images and loaded the images that were needed at runtime. But they also had to delete the images again when they were not necessary anymore.</p>
<p>Solution: the BitmapData class has a very usefull dispose() function you can use to get rid of the real pixel data.</p>

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

<p><strong>Trick 3:</strong></p>
<p>Use a memory monitoring class so that you can keep an eye out on the -real- memory usage of your Flash. A good, but hard to find class is: ActiveGraph created by rezmason.</p>
<p>I added the class here to make it easy for you. Don&#8217;t forget to thank rezmason for the great class :p.</p>
<p><a href='http://www.bartclaessens.com/wp-content/uploads/2009/05/activegraph.zip'>ActiveGraph Class</a></p>
<p>That&#8217;s it for now. Not that much hu? Well, this is certainly not the end, keep an eye out on my blog because I feel we have to do a lot more performance tweaking :p</p>
<div class="shr-publisher-30"></div>]]></content:encoded>
			<wfw:commentRss>http://www.bartclaessens.com/2008/09/some-actionscript-optimization-tricks-and-good-practises/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

