<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>actionscript-3 &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/actionscript-3/</link>
	<description>Feed of posts on WordPress.com tagged "actionscript-3"</description>
	<pubDate>Sun, 27 Dec 2009 01:36:39 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[AS3 Events part 3 - Mouse events]]></title>
<link>http://actiontuts.wordpress.com/2009/12/19/as3-events-part-3-mouse-events/</link>
<pubDate>Sat, 19 Dec 2009 06:48:39 +0000</pubDate>
<dc:creator>Paul Cotos</dc:creator>
<guid>http://actiontuts.wordpress.com/2009/12/19/as3-events-part-3-mouse-events/</guid>
<description><![CDATA[OK &#8230;.I know I haven&#8217;t posted anything for a long time, but I was busy @ work and had no ]]></description>
<content:encoded><![CDATA[OK &#8230;.I know I haven&#8217;t posted anything for a long time, but I was busy @ work and had no ]]></content:encoded>
</item>
<item>
<title><![CDATA[DisplayObjects Round Their X and Y Properties, Makes Brownian Motion Difficult]]></title>
<link>http://summitprojectsflashblog.wordpress.com/2009/12/17/displayobjects-round-their-x-and-y-properties-makes-brownian-motion-difficult/</link>
<pubDate>Thu, 17 Dec 2009 00:43:00 +0000</pubDate>
<dc:creator>Dru Kepple</dc:creator>
<guid>http://summitprojectsflashblog.wordpress.com/2009/12/17/displayobjects-round-their-x-and-y-properties-makes-brownian-motion-difficult/</guid>
<description><![CDATA[Earl and I just hammered out a weird issue in some code that involved Brownian motion. Check this ou]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Earl and I just hammered out a weird issue in some code that involved Brownian motion.  Check this out, assuming <code>p</code> is a MovieClip on the stage:</p>
<pre><code>addEventListener(Event.ENTER_FRAME, animate);

function animate(e:Event):void {
    p.x += Math.random() * 2 - 1;
    p.y += Math.random() * 2 - 1;
}
</code></pre>
<p>Seems simple enough, right?  The particle <code>p</code> should move randomly, and produce what is called &#8220;Brownian motion.&#8221;  It should wander, but ultimately stay within a general area, on average.</p>
<p>However, if you let it run long, you&#8217;ll find the particle tending to gravitate to 0, 0.  If you&#8217;re impatient, you can speed up the process like this:</p>
<pre><code>addEventListener(Event.ENTER_FRAME, animate);

function animate(e:Event):void {
    <strong>for (var i:int = 0; i &#60; 100; i++) {</strong>
        p.x += Math.random() * 2 - 1;
        p.y += Math.random() * 2 - 1;
    <strong>}</strong>
}
</code></pre>
<p>After trying quite a few things, we eventually tried the following:</p>
<pre><code>addEventListener(Event.ENTER_FRAME, animate);

<strong>var realX:Number = p.x;</strong>
<strong>var realY:Number = p.y;</strong>

function animate(e:Event):void {
    <strong>realX += Math.random() * 2 - 1;</strong>
    <strong>realY += Math.random() * 2 - 1;</strong>
    p.x = realX;
    p.y = realY;
}
</code></pre>
<p>Again, you can wrap that up in the loop to speed things up.</p>
<p>Either way, you&#8217;ll notice that we get proper motion now.  What gives?</p>
<p>Well, the suspicion that lead to us trying that was confirmed when we added a trace:</p>
<pre><code>addEventListener(Event.ENTER_FRAME, animate);

var realX:Number = p.x;
var realY:Number = p.y;

function animate(e:Event):void {
    realX += Math.random() * 2 - 1;
    realY += Math.random() * 2 - 1;
    p.x = realX;
    p.y = realY;

    <strong>trace(realX, p.x);</strong>
}
</code></pre>
<p>You&#8217;ll see something like this:</p>
<pre><code>310.60525778401643 310.6
311.387398567982 311.35
312.1899666218087 312.15
311.5306175108999 311.5
311.22865250799805 311.2
311.0907105393708 311.05
310.28716491162777 310.25
309.4788754032925 309.45
309.128194604069 309.1
308.98307433445007 308.95
309.23653392959386 309.2
308.6192215178162 308.6
309.3771039834246 309.35
</code></pre>
<p>Check <em>that</em> out!  The x property (and the y, too, we checked) is rounded internally to the nearest .05.  Actually, it&#8217;s not even rounded, it&#8217;s floored (my assumption is that it&#8217;s just truncating some bits resulting in a floor effect, which would presumably be a faster operation that <code>Math.floor</code>).</p>
<p>So, basically, we&#8217;re talking about rounding errors that, when piled up, result in a gradual approach to 0.  For example, say you start at 10.  You generate your random number, and it&#8217;s -1.46.  You take x property of 10, subtract 1.46, and you&#8217;d expect to end up at 8.54.  Instead, you end up 8.5.  Confirm it with the following code:</p>
<pre><code>p.x = 10;
p.x += -1.46
trace(p.x);
trace(10 - 1.46)
</code></pre>
<p>A similar effect happens with positive numbers&#8230;you end up smaller than you think you will.  Thus, a gradual approach to 0.</p>
<p>The fix involves tracking a high-precision Number value as the &#8220;real&#8221; x and y, and adding to that.  Then, simply assigning that value to the MovieClip&#8217;s x and y still results in rounding, but without any cumulative effects.  Anyone else remember the similar problem from ActionScript 2 days with <code>_alpha</code>?</p>
<p>My theory is that since there is a finite precision to Numbers, we&#8217;d still see a gradual approach to 0, only it&#8217;ll take MUCH longer.</p>
<p>So, I&#8217;m not necessarily pointing the finger at Adobe here and saying this is a bug; this is clearly intentional behavior, and 99% of the time you don&#8217;t even notice.  But when you do have that situation where it matters, you need to know about it.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Sorting date columns in a DataGrid | Flex Examples ]]></title>
<link>http://benjaminwss.wordpress.com/2009/12/16/sorting-date-columns-in-a-datagrid-flex-examples/</link>
<pubDate>Wed, 16 Dec 2009 08:41:19 +0000</pubDate>
<dc:creator>Benjamin Wong</dc:creator>
<guid>http://benjaminwss.wordpress.com/2009/12/16/sorting-date-columns-in-a-datagrid-flex-examples/</guid>
<description><![CDATA[Sorting date columns in a DataGrid by Peter deHaan on August 12, 2007 in DataGrid, ObjectUtil Here’s]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div class="posterous_bookmarklet_entry">
<blockquote class="posterous_long_quote">
<div class="headline_area">
<h1 class="entry-title">Sorting date columns in a DataGrid</h1>
<p class="headline_meta">by <span class="author vcard"><a class="url fn" href="http://blog.flexexamples.com/author/admin/">Peter deHaan</a></span> on <abbr class="published" title="2007-08-12">August 12, 2007</abbr></p>
<p class="headline_meta">in <a title="View all posts in DataGrid" rel="category tag" href="http://blog.flexexamples.com/category/halo/datagrid/">DataGrid</a>, <a title="View all posts in ObjectUtil" rel="category tag" href="http://blog.flexexamples.com/category/objectutil/">ObjectUtil</a></p>
</div>
<div class="format_text entry-content">
<p>Here’s an example of sorting a column of dates in a Flex DataGrid. The dates start out as Strings (such as “04/14/1980″) so you create a custom <code>sortCompareFunction</code> on that DataGrid column which converts the strings to dates so Flex will sort the dates in sequential order (as oppsed to string order). Hope that helps somebody out there.</p>
<p>I also created a little tooltip on the date column which shows the dates in a somewhat more readable form (”April 14 1980″) using the DataGridColumn object’s <code>showDataTips</code> and <code>dataTipFunction</code> properties.</p>
<p>Full code after the jump.</p>
<pre>
<pre>
<pre>&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;!-- <a href="http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/">http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/</a> --&#62;
&#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&#62;

    &#60;mx:Script&#62;
        &#60;![CDATA[
            import mx.utils.ObjectUtil;

            private function date_sortCompareFunc(itemA:Object, itemB:Object):int {
                /* Date.parse() returns an int, but
                   ObjectUtil.dateCompare() expects two
                   Date objects, so convert String to
                   int to Date. */
                var dateA:Date = new Date(Date.parse(itemA.dob));
                var dateB:Date = new Date(Date.parse(itemB.dob));
                return ObjectUtil.dateCompare(dateA, dateB);
            }

            private function date_dataTipFunc(item:Object):String {
                return dateFormatter.format(item.dob);
            }
        ]]&#62;
    &#60;/mx:Script&#62;

    &#60;mx:ArrayCollection id="arrColl"&#62;
        &#60;mx:source&#62;
            &#60;mx:Array&#62;
                &#60;mx:Object name="User A" dob="04/14/1980" /&#62;
                &#60;mx:Object name="User B" dob="01/02/1975" /&#62;
                &#60;mx:Object name="User C" dob="12/30/1977" /&#62;
                &#60;mx:Object name="User D" dob="10/27/1968" /&#62;
            &#60;/mx:Array&#62;
        &#60;/mx:source&#62;
    &#60;/mx:ArrayCollection&#62;

    &#60;mx:DateFormatter id="dateFormatter" formatString="MMMM D, YYYY" /&#62;

    &#60;mx:DataGrid id="dataGrid" dataProvider="{arrColl}"&#62;
        &#60;mx:columns&#62;
            &#60;mx:DataGridColumn dataField="name"
                    headerText="Name:" /&#62;

            &#60;mx:DataGridColumn dataField="dob"
                    headerText="Date of birth:"
                    sortCompareFunction="date_sortCompareFunc"
                    showDataTips="true"
                    dataTipFunction="date_dataTipFunc" /&#62;
        &#60;/mx:columns&#62;
    &#60;/mx:DataGrid&#62;

&#60;/mx:Application&#62;</pre>
</pre>
</pre>
<p class="post_tags">Tagged as:  					  <a rel="tag" href="http://blog.flexexamples.com/tag/datatipfunction/">dataTipFunction</a>,   						<a rel="tag" href="http://blog.flexexamples.com/tag/datecompare/">dateCompare()</a>,   						<a rel="tag" href="http://blog.flexexamples.com/tag/showdatatips/">showDataTips</a>,   						<a rel="tag" href="http://blog.flexexamples.com/tag/sortcomparefunction/">sortCompareFunction</a></p>
</div>
</blockquote>
<div class="posterous_quote_citation">via <a href="http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/">blog.flexexamples.com</a></div>
<p>Stored as a note on how to create a custom compare function in Flex</p>
</div>


<!-- No posting client link spam, please. -->


</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Displaying the sort arrow in a Flex DataGrid control without having to click a column | Flex Examples]]></title>
<link>http://benjaminwss.wordpress.com/2009/12/16/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column-flex-examples/</link>
<pubDate>Wed, 16 Dec 2009 08:37:04 +0000</pubDate>
<dc:creator>Benjamin Wong</dc:creator>
<guid>http://benjaminwss.wordpress.com/2009/12/16/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column-flex-examples/</guid>
<description><![CDATA[Displaying the sort arrow in a Flex DataGrid control without having to click a column by Peter deHaa]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div class="posterous_bookmarklet_entry">
<blockquote class="posterous_long_quote">
<div class="headline_area">
<h1 class="entry-title">Displaying the sort arrow in a Flex DataGrid control without having to click a column</h1>
<p class="headline_meta">by <span class="author vcard"><a class="url fn" href="http://blog.flexexamples.com/author/admin/">Peter deHaan</a></span> on <abbr class="published" title="2008-02-28">February 28, 2008</abbr></p>
<p class="headline_meta">in <a title="View all posts in DataGrid" rel="category tag" href="http://blog.flexexamples.com/category/halo/datagrid/">DataGrid</a>, <a title="View all posts in Sort" rel="category tag" href="http://blog.flexexamples.com/category/sort/">Sort</a>, <a title="View all posts in SortField" rel="category tag" href="http://blog.flexexamples.com/category/sortfield/">SortField</a></p>
</div>
<div class="format_text entry-content">
<p>I’ve seen this question come up a few times recently in various forums/lists and even in my blog comments (see <a href="http://blog.flexexamples.com/2008/02/23/changing-the-default-sort-arrow-skin-on-a-flex-datagrid-control/">“Changing the default sort arrow skin on a Flex DataGrid control”</a>).</p>
<p>The following example shows how you can display the sort arrow in a DataGrid control in Flex without having the user click on a column header in the DataGrid control.</p>
<p>Full code after the jump.</p>
<div class="wp_syntax">
<div class="code">
<pre class="mxml" style="font-family:monospace;">
<pre>&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:Application name="DataGrid_dataProvider_sort_fields_test"&#62;
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&#62;

    &#60;mx:Script&#62;
        &#60;![CDATA[
            import mx.collections.Sort;
            import mx.collections.SortField;

            private function init():void {
                arrColl.sort = new Sort();
                arrColl.sort.fields = [new SortField("idx", false, true)];
                arrColl.refresh();
            }
        ]]&#62;
    &#60;/mx:Script&#62;

    &#60;mx:ArrayCollection id="arrColl"&#62;
        &#60;mx:source&#62;
            &#60;mx:Array&#62;
                &#60;mx:Object idx="1" c1="One.1" c2="One.2" /&#62;
                &#60;mx:Object idx="2" c1="Two.1" c2="Two.2" /&#62;
                &#60;mx:Object idx="3" c1="Three.1" c2="Three.2" /&#62;
                &#60;mx:Object idx="4" c1="Four.1" c2="Four.2" /&#62;
                &#60;mx:Object idx="5" c1="Five.1" c2="Five.2" /&#62;
                &#60;mx:Object idx="6" c1="Six.1" c2="Six.2" /&#62;
                &#60;mx:Object idx="7" c1="Seven.1" c2="Seven.2" /&#62;
                &#60;mx:Object idx="8" c1="Eight.1" c2="Eight.2" /&#62;
                &#60;mx:Object idx="9" c1="Nine.1" c2="Nine.2" /&#62;
                &#60;mx:Object idx="10" c1="Ten.1" c2="Ten.2" /&#62;
                &#60;mx:Object idx="11" c1="Eleven.1" c2="Eleven.2" /&#62;
                &#60;mx:Object idx="12" c1="Twelve.1" c2="Twelve.2" /&#62;
                &#60;mx:Object idx="13" c1="Thirteen.1" c2="Thirteen.2" /&#62;
            &#60;/mx:Array&#62;
        &#60;/mx:source&#62;
    &#60;/mx:ArrayCollection&#62;

    &#60;mx:DataGrid id="dataGrid"
            dataProvider="{arrColl}"
            creationComplete="init();"&#62;
        &#60;mx:columns&#62;
            &#60;mx:DataGridColumn dataField="idx" /&#62;
            &#60;mx:DataGridColumn dataField="c1" /&#62;
            &#60;mx:DataGridColumn dataField="c2" /&#62;
        &#60;/mx:columns&#62;
    &#60;/mx:DataGrid&#62;

&#60;/mx:Application&#62;</pre>
</pre>
</div>
</div>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGrid_dataProvider_sort_fields_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p>A big thanks to Rob for the heads up with the solution!</p>
<p>For more information, see <a href="http://bugs.adobe.com/jira/browse/SDK-14663">http://bugs.adobe.com/jira/browse/SDK-14663</a>.</p>
<p><span style="clear:both;display:none;"><img style="height:0;display:none;border-style:none;" src="http://blog.flexexamples.com/wp-content/plugins/wp-spamfree/img/wpsf-img.php" alt="" width="0" height="0" /></span> &#8211;&#62;</p>
<p class="post_tags">Tagged as:  						<a rel="tag" href="http://blog.flexexamples.com/tag/fields/">fields</a></p>
</div>
</blockquote>
<div class="posterous_quote_citation">via <a href="http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/">blog.flexexamples.com</a></div>
<p>Good tutorial for Flex development. Shows how to apply a client side sort which in turn will affect how the data grid&#8217;s array is displayed.</p>
</div>


<!-- No posting client link spam, please. -->


</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[AS3 Transparency of Video Objects]]></title>
<link>http://taeschi.wordpress.com/2009/12/13/as3-transparency-of-video-objects/</link>
<pubDate>Sun, 13 Dec 2009 13:30:18 +0000</pubDate>
<dc:creator>taeschi</dc:creator>
<guid>http://taeschi.wordpress.com/2009/12/13/as3-transparency-of-video-objects/</guid>
<description><![CDATA[Hey guys and girls, my project this semester made me search for a way to get transparency out of a v]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Hey guys and girls,</p>
<p>my project this semester made me search for a way to get transparency out of a video-file in Actionscript 3. Thanks to nice guys in a flash-forum (<a href="http://www.flashforum.de/forum/actionscript-3/video-transparenzen-zu-einem-bestimmten-zeitpunkt-ermitteln-276793.html">forum&#8217;s thread</a>) I found a nice solution:</p>
<p class="code">
<pre class="brush: as3;">
var tmp:BitmapData = new BitmapData(100,100);
tmp.draw( Video(getChildByName(&#34;video&#34;)) );
var alpha:int = tmp.getPixel32(event.localX,event.localY);
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Flash AS3 Custom XML Class]]></title>
<link>http://dineshpeiris.wordpress.com/2009/12/12/flash-as3-custom-xml-class/</link>
<pubDate>Sat, 12 Dec 2009 02:03:32 +0000</pubDate>
<dc:creator>Dinesh Peiris</dc:creator>
<guid>http://dineshpeiris.wordpress.com/2009/12/12/flash-as3-custom-xml-class/</guid>
<description><![CDATA[CustomEvent.as package map.xmlload{ import flash.events.Event; public class CustomEvent extends Even]]></description>
<content:encoded><![CDATA[CustomEvent.as package map.xmlload{ import flash.events.Event; public class CustomEvent extends Even]]></content:encoded>
</item>
<item>
<title><![CDATA[AS3 ImageLoader Class]]></title>
<link>http://dineshpeiris.wordpress.com/2009/12/12/as3-imageloader-class/</link>
<pubDate>Sat, 12 Dec 2009 01:57:07 +0000</pubDate>
<dc:creator>Dinesh Peiris</dc:creator>
<guid>http://dineshpeiris.wordpress.com/2009/12/12/as3-imageloader-class/</guid>
<description><![CDATA[Load bitmap images in OOP concept. Simple and easy custom image loader class, import &lt;package nam]]></description>
<content:encoded><![CDATA[Load bitmap images in OOP concept. Simple and easy custom image loader class, import &lt;package nam]]></content:encoded>
</item>
<item>
<title><![CDATA[FIVe3D Living Surface]]></title>
<link>http://dineshpeiris.wordpress.com/2009/12/06/five3d-living-surface/</link>
<pubDate>Sun, 06 Dec 2009 22:29:02 +0000</pubDate>
<dc:creator>Dinesh Peiris</dc:creator>
<guid>http://dineshpeiris.wordpress.com/2009/12/06/five3d-living-surface/</guid>
<description><![CDATA[Awesome work I did using FIVe3D]]></description>
<content:encoded><![CDATA[Awesome work I did using FIVe3D]]></content:encoded>
</item>
<item>
<title><![CDATA[Papervision3D Application for Ubiq Window]]></title>
<link>http://dineshpeiris.wordpress.com/2009/12/06/papervision3d-application-for-ubiq-window/</link>
<pubDate>Sun, 06 Dec 2009 22:17:49 +0000</pubDate>
<dc:creator>Dinesh Peiris</dc:creator>
<guid>http://dineshpeiris.wordpress.com/2009/12/06/papervision3d-application-for-ubiq-window/</guid>
<description><![CDATA[My 1st Papervision3D application for Ubiq Window API. I push the boundaries of Papervision3D with th]]></description>
<content:encoded><![CDATA[My 1st Papervision3D application for Ubiq Window API. I push the boundaries of Papervision3D with th]]></content:encoded>
</item>
<item>
<title><![CDATA["Error #1088: The markup in the document following the root element must be well-formed."]]></title>
<link>http://maohao.wordpress.com/2009/12/05/error-1088-the-markup-in-the-document-following-the-root-element-must-be-well-formed/</link>
<pubDate>Sun, 06 Dec 2009 03:25:29 +0000</pubDate>
<dc:creator>maohao</dc:creator>
<guid>http://maohao.wordpress.com/2009/12/05/error-1088-the-markup-in-the-document-following-the-root-element-must-be-well-formed/</guid>
<description><![CDATA[I was using PHP and curl as proxy to get some xml files from Basecamp for my Flex UI to consume and ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I was using PHP and curl as proxy to get some xml files from <a title="Basecamp" href="http://basecamphq.com/" target="_blank">Basecamp </a>for my Flex UI to consume and was successful (something like &#8220;<code>return $response   = curl_exec($session);</code>&#8220;. But after I refactored my little php functions into an object/class and included it in another delegation file, it suddenly stopped working. In Flex, I got the following error for the HTTPService fault event:</p>
<blockquote><p>faultCode:Client.CouldNotDecode<br />
faultString:&#8217;Error #1088: The markup in the document following the root element must be well-formed.&#8217;<br />
faultDetail:&#8217;null&#8217;</p></blockquote>
<p>In Firefox 3.5, the output XML file looked ok. But both Safari and IE gave error messages: There was an &#8220;*&#8221; in front of the &#60;?xml ..?&#62; header in Safari source code view; while IE gave the following error:</p>
<blockquote><p>Invalid at the top level of the document. Error processing resource</p></blockquote>
<p>After comparing the files before refactoring and the one after, I noticed that the refactored one was encoded in UTF-8 while the old one was in ANSI. After I converted my class file into ANSI, XML output became normal in all three browsers.</p>
<p>BTW, I used <a title="Notepad++" href="http://notepad-plus.sourceforge.net" target="_blank">Notepad++</a>. Not sure if that was an issue.</p>
<p>Anyhow, lessons learned: <strong>Make sure the source files are encoded in ANSI</strong>.</p>
<p>Any comments and thoughts are welcome!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Testing Source Code]]></title>
<link>http://skarh.wordpress.com/2009/12/04/testing-source-code/</link>
<pubDate>Fri, 04 Dec 2009 19:26:58 +0000</pubDate>
<dc:creator>Sheel</dc:creator>
<guid>http://skarh.wordpress.com/2009/12/04/testing-source-code/</guid>
<description><![CDATA[I just read this article from the team behind WordPress. And I just wanted to test it out with a sma]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I just read <a href="http://en.blog.wordpress.com/2009/12/02/better-source-code-posting/" target="_blank">this article</a> from the team behind WordPress.</p>
<p><!--more--></p>
<p>And I just wanted to test it out with a small chunk of code from my recently created <a href="http://jeldre.deviantart.com/art/Rock-Paper-Scissor-143928744" target="_blank">Flash platform game</a>.</p>
<pre class="brush: as3;">
		private function checkKeysDown (event:KeyboardEvent):void
		{
			if(event.keyCode == 37 &#124;&#124; event.keyCode == 65) 			// A or Left Arrow
			{
				leftKeyDown = true;
				rightKeyDown = false;
			}

			if(event.keyCode == 38 &#124;&#124; event.keyCode == 87) 			// W or Up Arrow
			{
				upKeyDown = true;
			}

			if(event.keyCode == 39 &#124;&#124; event.keyCode == 68) 			// D or Right Arrow
			{
				rightKeyDown = true;
				leftKeyDown = false;
			}

			if(event.keyCode == 72 &#38;&#38; !mainJumping) 				// H key
			{
				hKeyDown = true;
				sc4 = attack.play();
			}

			if(event.keyCode == 74 &#38;&#38; !mainJumping) 				// J key
			{
				jKeyDown = true;
				sc4 = attack.play();
			}

			if(event.keyCode == 75 &#38;&#38; !mainJumping) 				// K key
			{
				kKeyDown = true;
				sc4 = attack.play();
			}
		} // end private function checkKeysDown
</pre>
<p>Seems like it works wonderfully, I don&#8217;t know why I haven&#8217;t checked this functionality out before now. But I can see a lot of uses for this seeing as I&#8217;ve recently learned a lot of ActionScript 3.0 and will start learning more HTML and CSS in the following courses I have. Expect more posts consisting of code-strings in large amounts!</p>
<p>One awesome thing with this &#8220;plugin&#8221; is that it supports a lot of different programming languages; meaning that the plugin can color-code different syntaxes with various colors typically found within the language. It&#8217;s brilliant.</p>
<p>To insert code like this you simply write:</p>
<blockquote><p>[*sourcecode language="css"]<br />
your code here<br />
[*/sourcecode]</p></blockquote>
<p>Without the wildcard (*)</p>
<p>If you don&#8217;t define the source code language it will be &#8220;text&#8221; by default (no syntax highlighting). Here&#8217;s a list of the supported languages</p>
<ul>
<li> actionscript3</li>
<li>bash</li>
<li>coldfusion</li>
<li>cpp</li>
<li>csharp</li>
<li>css</li>
<li>delphi</li>
<li>erlang</li>
<li>diff</li>
<li>groovy</li>
<li>javascript</li>
<li>java</li>
<li>javafx</li>
<li>objc</li>
<li>perl</li>
<li>php</li>
<li>text</li>
<li>powershell</li>
<li>python</li>
<li>ruby</li>
<li>scala</li>
<li>sql</li>
<li>vb</li>
<li>xml</li>
</ul>
<p>Here&#8217;s the <a href="http://en.support.wordpress.com/code/posting-source-code/" target="_blank">support post for the Source Code</a> tagging.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Block statements in control flow constructs]]></title>
<link>http://maohao.wordpress.com/2009/12/02/block-statements-in-control-flow-constructs/</link>
<pubDate>Wed, 02 Dec 2009 18:00:18 +0000</pubDate>
<dc:creator>maohao</dc:creator>
<guid>http://maohao.wordpress.com/2009/12/02/block-statements-in-control-flow-constructs/</guid>
<description><![CDATA[There is no need to block (using braces to wrap) single line statements in a control flow (as-if, do]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>There is no need to block (using braces to wrap) single line statements in a control flow (<em>as-if</em>, <em>do-while</em>, <em>for/while</em>); and you can mix blocks and non block statements together like this:</p>
<blockquote><p>if(num &#62; 0)<br />
trace(num+&#8221; is positive;\n&#8221;);<br />
else if(num &#60;0)<br />
{<br />
trace(num+&#8221; is negative.&#8221;);<br />
trace(num+&#8221; don&#8217;t be negative;\n&#8221;);<br />
}<br />
else if(num == 0)<br />
trace(num+&#8221; is neutral;\n&#8221;);</p></blockquote>
<p>This applies to all the control statements although the example here is just of<em> if/else</em> .</p>
<p>With this being said,<a title="The Elements of C# Style" href="http://www.amazon.com/Elements-C-Style-Kenneth-Baldwin/dp/0521671590" target="_blank"> The Elements of C# Style</a> recommends <em>Always us block statements in control flow constructs.</em> Reason one is that it makes it easy to add additional statements in it; reason two is it&#8217;s easier to read than those without blocks.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Flash AS3 with CSS]]></title>
<link>http://dineshpeiris.wordpress.com/2009/11/27/flash-as3-with-css/</link>
<pubDate>Fri, 27 Nov 2009 10:39:55 +0000</pubDate>
<dc:creator>Dinesh Peiris</dc:creator>
<guid>http://dineshpeiris.wordpress.com/2009/11/27/flash-as3-with-css/</guid>
<description><![CDATA[You can find simple Flash AS3 Class connected with CSS. You can create Flash User Registration form ]]></description>
<content:encoded><![CDATA[You can find simple Flash AS3 Class connected with CSS. You can create Flash User Registration form ]]></content:encoded>
</item>
<item>
<title><![CDATA[Actionscript 3.0, printJob and a black page!]]></title>
<link>http://rivetgirl.wordpress.com/2009/11/22/actionscript-3-0-printjob-and-a-black-page/</link>
<pubDate>Sun, 22 Nov 2009 18:11:47 +0000</pubDate>
<dc:creator>rivetgirl</dc:creator>
<guid>http://rivetgirl.wordpress.com/2009/11/22/actionscript-3-0-printjob-and-a-black-page/</guid>
<description><![CDATA[Talk about figuring out something the hard way, I had to add print functionality to a flash advent c]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Talk about figuring out something the hard way, I had to add print functionality to a flash advent calendar and upon testing in a browser began printing pages that would first print what I was expecting but then added a lovely black box at the bottom of the page. I had added a white background box to the page at the beginning but after much beating my head came to realize that it just wasn&#8217;t long enough and the printer interpreted the empty space as black, I extended the white box and voila! page prints only the items I want and no more black box. I&#8217;d seen a few posts about this with no solution so hopefully this helps someone else out there beating their heads over something silly.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[3d engines in Flash]]></title>
<link>http://kirillpoletaev.wordpress.com/2009/11/21/3d-in-flash/</link>
<pubDate>Sat, 21 Nov 2009 20:03:22 +0000</pubDate>
<dc:creator>Kirill Poletaev</dc:creator>
<guid>http://kirillpoletaev.wordpress.com/2009/11/21/3d-in-flash/</guid>
<description><![CDATA[I must say that at the moment I know almost nothing about 3d, and I&#8217;m starting with the beginn]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I must say that at the moment I know almost nothing about 3d, and I&#8217;m starting with the beginner tutorials. So far I&#8217;ve seen three flash 3d engines:</p>
<p><strong>Away3D</strong> &#8211; a powerful, widely-used and good looking 3d engine, free to use.</p>
<p>http://away3d.com</p>
<p><img class="alignnone" title="Away3D demo screenshot" src="http://away3d.com/awaygraphics/away3d-eminem-1.jpg" alt="" width="280" height="175" /></p>
<p><strong>Papervision3D</strong> &#8211; a clean, fast, popular 3d flash engine.<br />
<a href="http://blog.papervision3d.org/">http://blog.papervision3d.org/</a></p>
<p><img class="alignnone" title="Papervision3D demo screenshot" src="http://www.neoteo.com/Portals/0/imagenes/cache/6B54x1500y1500.jpg" alt="" width="280" height="156" /></p>
<p><strong>Alternativa3D</strong> &#8211; probably the most powerful 3d engine in flash, created by russian programmers, which is still in development. However, it won&#8217;t be free.<br />
<a href="http://alternativaplatform.com/ru/alternativa3d/">http://alternativaplatform.com/ru/alternativa3d/</a></p>
<p><img class="alignnone" title="Alternativa3D demo screenshot" src="http://alternativaplatform.com/img/demos/tank_scr.jpg" alt="" width="280" height="210" /></p>
<p>That&#8217;s it for now.</p>
<p>Have a nice day everyone!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Adobe Flash 3D world]]></title>
<link>http://dineshpeiris.wordpress.com/2009/11/16/adobe-flash-3d-world-2/</link>
<pubDate>Mon, 16 Nov 2009 10:39:01 +0000</pubDate>
<dc:creator>Dinesh Peiris</dc:creator>
<guid>http://dineshpeiris.wordpress.com/2009/11/16/adobe-flash-3d-world-2/</guid>
<description><![CDATA[Flash is primarily a two dimensional environment so typically a library is used to display and manag]]></description>
<content:encoded><![CDATA[Flash is primarily a two dimensional environment so typically a library is used to display and manag]]></content:encoded>
</item>
<item>
<title><![CDATA[Beware of DisplayObject.getBounds]]></title>
<link>http://summitprojectsflashblog.wordpress.com/2009/11/15/beware-of-displayobject-getbounds/</link>
<pubDate>Sun, 15 Nov 2009 23:13:03 +0000</pubDate>
<dc:creator>amoslanka</dc:creator>
<guid>http://summitprojectsflashblog.wordpress.com/2009/11/15/beware-of-displayobject-getbounds/</guid>
<description><![CDATA[It may not be obvious until you actually make the mistake and spend half a day trying to find the mi]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>It may not be obvious until you actually make the mistake and spend half a day trying to find the miscalculation in what you thought was an intuitive use of flash&#8217;s built in tools. DisplayObjects have the getBounds method, allowing you to quickly retrieve a Rectangle object containing size and location properties pertaining to that object in relation to any other display object, whether on the stage or not. Passing a reference of a clip into its own getBounds method returns a rectangle complete relative to itself, very handy for quickly retrieving an object&#8217;s dimensions.</p>
<p>Be careful, however, because using this method of retrieving an object&#8217;s dimensions is very relative. When asked for dimensions relative to itself, a DisplayObject will return unscaled values. So if you&#8217;ve rescaled a MovieClip on the stage and plan to quickly pass around its size dimensions, you&#8217;ll be better off creating your own Rectangle than relying  on getBounds, especially when there&#8217;s a possibility that the object is not its original width or height.</p>
<p>Furthermore, it may be dangerous in a dynamic situation to simply getBounds against the object&#8217;s parent, and the object&#8217;s root property is only valid if the clip is somewhere on the stage. In these situations it may be best to either go through the extra motions of constructing your own rectangle or only use object.getBounds(object) when you&#8217;re positive the object is not scaled.</p>
<p><code>var square:Sprite = new Sprite();<br />
addChild(square);<br />
square.graphics.beginFill(0x0000FF);<br />
square.graphics.drawRect(0,0,100,100);<br />
square.graphics.endFill();<br />
square.x = stage.stageWidth/2 - square.width/2;<br />
square.y = stage.stageHeight/2 - square.height/2;</code></p>
<p><code>var b:Rectangle;<br />
b = square.getBounds(this);<br />
trace(b);  // traces (x=225, y=150, w=100, h=100)</p>
<p>square.scaleX = 2;</p>
<p></code></p>
<p><code>b = square.getBounds(square);<br />
trace(b);   // traces (x=0, y=0, w=100, h=100)<br />
</code></p>
<p>So do not expect the second trace in this code block to return a rectangle with a width of 200. Being a completely relative call it will return the object&#8217;s independent width within its scaled universe. As I mentioned, it makes sense from an oop standpoint, but its easy to hope or expect a scaled return if you&#8217;re needing that returned in a situation.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Développer en Flash... sans Flash]]></title>
<link>http://olilamont.wordpress.com/2009/11/15/developper-en-flash-sans-flash/</link>
<pubDate>Sun, 15 Nov 2009 18:01:07 +0000</pubDate>
<dc:creator>olilamont</dc:creator>
<guid>http://olilamont.wordpress.com/2009/11/15/developper-en-flash-sans-flash/</guid>
<description><![CDATA[Comment développer en Flash sans un seul fichier FLA? C&#8217;est très simple, et voici un petit tut]]></description>
<content:encoded><![CDATA[Comment développer en Flash sans un seul fichier FLA? C&#8217;est très simple, et voici un petit tut]]></content:encoded>
</item>

</channel>
</rss>
