<?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>polyGeek.com &#187; Actionscript 3</title>
	<atom:link href="http://polygeek.com/tag/actionscript-3/feed" rel="self" type="application/rss+xml" />
	<link>http://polygeek.com</link>
	<description>polyGeek (noun) person with many geek related talents.</description>
	<lastBuildDate>Fri, 11 May 2012 20:45:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Search Engine dedicated to Actionscript and Flex</title>
		<link>http://polygeek.com/3459_flex_search-engine-dedicated-to-actionscript-and-flex</link>
		<comments>http://polygeek.com/3459_flex_search-engine-dedicated-to-actionscript-and-flex#comments</comments>
		<pubDate>Tue, 08 Feb 2011 16:46:00 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=3459</guid>
		<description><![CDATA[Next time you&#8217;re searching for help on some problem you&#8217;re having with Actionscript/Flex &#8211; which if you&#8217;re like me is about every 15 minutes &#8211; then try using flex.paulsearch.co. It...]]></description>
			<content:encoded><![CDATA[<p>Next time you&#8217;re searching for help on some problem you&#8217;re having with Actionscript/Flex &#8211; which if you&#8217;re like me is about every 15 minutes &#8211; then try using <a href="http://flex.paulsearch.co/">flex.paulsearch.co</a>. It searches across hundreds of blogs that are written by people in the Flash Platform Community. The nice thing is that it weeds out a lot of the results that come back that are related to other languages.</p>
<p>You can see the <a href="http://flex.paulsearch.co/index.php/info/sites">entire list of sites that are included in the search</a>. If you see one that&#8217;s missing let Paul know about it.</p>
<p><a href="http://polygeek.com/3459_flex_search-engine-dedicated-to-actionscript-and-flex" rel="bookmark">Search Engine dedicated to Actionscript and Flex</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on February 8, 2011.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/3459_flex_search-engine-dedicated-to-actionscript-and-flex/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Using graphics.copyFrom to CircleTheWagons</title>
		<link>http://polygeek.com/3202_flex_graphics-copyfrom-circlethewagons</link>
		<comments>http://polygeek.com/3202_flex_graphics-copyfrom-circlethewagons#comments</comments>
		<pubDate>Wed, 08 Dec 2010 04:31:45 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[drawingAPI]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=3202</guid>
		<description><![CDATA[CircleTheWagons will take an arbitrary Sprite and repeatedly place copies of that Sprite around the perimeter of a circle. Presumably you have drawn something on the graphics layer of the...]]></description>
			<content:encoded><![CDATA[<p>CircleTheWagons will take an arbitrary Sprite and repeatedly place copies of that Sprite around the perimeter of a circle. Presumably you have drawn something on the graphics layer of the Sprite otherwise it&#8217;s sort of boring looking.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm__3202_CircleTheWagons_476239046"
			class="flashmovie"
			width="550"
			height="800">
	<param name="movie" value="http://polygeek.com/flex/3202_CircleTheWagons/_3202_CircleTheWagons.swf" />
	<param name="wmode" value="normal" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://polygeek.com/flex/3202_CircleTheWagons/_3202_CircleTheWagons.swf"
			name="fm__3202_CircleTheWagons_476239046"
			width="550"
			height="800">
		<param name="wmode" value="normal" />
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object></td>
</tr>
<tr>
<td align="center"><a href="http://polygeek.com/flex/3202_CircleTheWagons/srcview/index.html" target="code">view source</a></td>
</tr>
</tbody>
</table>
<p><strong>graphics.copyFrom</strong><br />
The real key to this approach is being able to copy the graphics drawn on one Sprite to many others. That is done via graphics.copyFrom as such:</p>
<pre>someEmptySprite.graphics.copyFrom( spriteWithStuffOnGraphicsLayer.graphics );</pre>
<p>Everything else is just looping through a number of times and placing the Sprites around a circle. The easiest way to do that is to use <a href="http://en.wikipedia.org/wiki/Polar_coordinate_system">polar coordinates</a> in the loop and then convert those coordinates to x,y for final placement. That way the Sprites can easily be rotated around so that they point to the center.</p>
<pre>
private function draw():void {
	// remove any existing sprites
	while( this.numChildren &gt; 0 ) {
		this.removeChildAt( 0 );
	}

	// Calculate how much to increase the angle each time through the loop.
	var increment:Number = ( 2 * Math.PI ) / _count;
	for( var angle:Number = 0; angle &lt; Math.PI * 2; angle+= increment ) {
		var s:Sprite = new Sprite();

		// Copy the graphics layer from _wagon onto the new Sprite.
		s.graphics.copyFrom( _wagon.graphics );

		// Place the Sprite by transforming the position from polar coordinates
		s.x = _radius * Math.cos( angle );
		s.y = _radius * Math.sin( angle );

		// If rotateInPlace is true then spin the Sprite.
		if( _rotateInPlace ) {
			s.rotation = 180 + angle * 180 / Math.PI;
		}
		this.addChild( s );
	}
}</pre>
<p>I suppose the next step would be to do the same thing but for Bitmaps. I&#8217;ll do that some other day.</p>
<p><a href="http://polygeek.com/3202_flex_graphics-copyfrom-circlethewagons" rel="bookmark">Using graphics.copyFrom to CircleTheWagons</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on December 7, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/3202_flex_graphics-copyfrom-circlethewagons/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Add commas to a number for readability</title>
		<link>http://polygeek.com/2314_flex_add-commas-to-a-number-for-readability</link>
		<comments>http://polygeek.com/2314_flex_add-commas-to-a-number-for-readability#comments</comments>
		<pubDate>Thu, 18 Feb 2010 20:40:13 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[utilities]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=2314</guid>
		<description><![CDATA[Do you need to display a large number and want to add commas to it for readability. The following code should work. Actually, it works for numbers that aren&#8217;t too...]]></description>
			<content:encoded><![CDATA[<p>Do you need to display a large number and want to add commas to it for readability. The following code should work. Actually, it works for numbers that aren&#8217;t too big. Not sure when it starts to break down but passing Number.MAX_VALUE definitely doesn&#8217;t work. :) But, for regular numbers smaller than the national debt you&#8217;re probably in luck.</p>
<pre style="font-family: monospace;">public static function commatizeNumber( n:Number ):String {
      var a:Array = new Array();
      var commatized:String = '';
      var decimal:String = '';
      if( int( n ) != n ) {
        // if the number isn't an integer then get everything after the decimal
        decimal = '.' + n.toString().split( '.' )[1];
        n = int( n ); // make n an integer
      }
      var numString:String = String( n );

      var place:int = numString.length; // start at the end
      while( place &gt; 0 ) {
        var s:String;
        // stop the while-loop
        if( place - 3 &lt; 0 ) {
           place = 0;
           s = numString.substr( 0, numString.length % 3 );
         } else {
           place -= 3;
           s = numString.substr( place, 3 );
         }

         a.push( s );
       }
       var len:int = a.length
       for( var i:int = len - 1; i &gt;= 0; i-- ) {
        // prevents the addition of a comma at the end of the String.
        commatized += ( i != 0 ) ? a[i] + ',' : a[i];
      }
      commatized += decimal;
      return commatized;
    }
</pre>
<p>This code seems a bit inelegant to me. Maybe it&#8217;s because I wrote it this morning before having coffee. :) Let me know if you see a way to make it better.</p>
<p><a href="http://polygeek.com/2314_flex_add-commas-to-a-number-for-readability" rel="bookmark">Add commas to a number for readability</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on February 18, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/2314_flex_add-commas-to-a-number-for-readability/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using the DrawingAPI to make wavy circles and stars</title>
		<link>http://polygeek.com/1802_flex_using-drawingapi-wavy-circles-stars</link>
		<comments>http://polygeek.com/1802_flex_using-drawingapi-wavy-circles-stars#comments</comments>
		<pubDate>Sun, 03 Jan 2010 03:18:26 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[drawingAPI]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=1802</guid>
		<description><![CDATA[Ingredients A bunch of Sprites 1 cup of graphics.lineStyle A dash of Vector3D and Matrix3D &#8211; adds an extra dimension to the dish ( ha-ha ) And most importantly a...]]></description>
			<content:encoded><![CDATA[<p><strong>Ingredients</strong></p>
<ul>
<li>A bunch of Sprites</li>
<li>1 cup of graphics.lineStyle</li>
<li>A dash of Vector3D and Matrix3D &#8211; adds an extra dimension to the dish ( ha-ha )</li>
<li>And most importantly a pinch of sin and cosine.</li>
</ul>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm__1802_Pattern_WavyCircles_2055628891"
			class="flashmovie"
			width="550"
			height="630">
	<param name="movie" value="http://polygeek.com/flex/1802_Pattern_WavyCircles/_1802_Pattern_WavyCircles.swf" />
	<param name="wmode" value="normal" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://polygeek.com/flex/1802_Pattern_WavyCircles/_1802_Pattern_WavyCircles.swf"
			name="fm__1802_Pattern_WavyCircles_2055628891"
			width="550"
			height="630">
		<param name="wmode" value="normal" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object></td>
</tr>
<tr>
<td align="center"><a href="http://polygeek.com/flex/1802_Pattern_WavyCircles/srcview/index.html">view source</a></td>
</tr>
</tbody>
</table>
<p><strong>Directions</strong></p>
<p>It is surprisingly easy to make this dish. The entire deal comes down to one line of code:</p>
<pre>s.graphics.lineTo( Math.sin( i + rotation ) * r, Math.cos( i + rotation ) * r );</pre>
<p>Once you have that the rest just falls into place. The entire WavyCircles class is only a few lines of code:</p>
<pre>[cc lang="actionscript3"]package com.polyGeek.patterns {
	import flash.display.Sprite;
	public class WavyCircle extends Sprite {
		public function WavyCircle( s:Sprite, radius:int, amplitude:int, period:int, rotation:Number ) {
			super();
			var step:Number = 0.01;
			var len:Number = 2 * Math.PI + step;
			for( var i:Number = -0.01; i &lt; len; i+= step ) {
var r:Number = radius + amplitude * ( Math.sin( period * i ) * Math.cos( period * i ) );	 				 				if( i &gt;= 0 ) {
					s.graphics.lineTo( Math.sin( i + rotation ) * r, Math.cos( i + rotation ) * r );
				} else {
					s.graphics.moveTo( Math.sin( i + rotation ) * r, Math.cos( i + rotation ) * r );
				}
			}
		}
	}
}[/cc]</pre>
<p>Ya see. That wasn&#8217;t so bad now was it? Most of the work on this came in the MXML and getting the auto-pilot and sliders going. Not hard. Just time consuming. I did all this coding back in the Spring &#8211; 9 months ago. I get a bit distracted over the summer and never published it. Of course I ported it over to Flex4 before putting it up. That was pretty easy. Most of the work was just replacing &#8220;&lt;mx&#8221; with &#8220;&lt;s&#8221; and that sort of thing. Not that I had to. Just wanted to.</p>
<p>I&#8217;d suggest turning off the auto-pilot and manually changing the <em>radius</em>, <em>amplitude, period </em>and <em>rotation.</em> Then take a look at the source code. It should be pretty easy to make since of it.</p>
<p>And yes, I should hook this up to an MP3 player and throw a few more WavyCircles in there that change based on the beat. Maybe later.</p>
<p><a href="http://polygeek.com/1802_flex_using-drawingapi-wavy-circles-stars" rel="bookmark">Using the DrawingAPI to make wavy circles and stars</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on January 2, 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/1802_flex_using-drawingapi-wavy-circles-stars/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Explorer for BitmapData.perlinNoise and BitmapData.noise</title>
		<link>http://polygeek.com/1780_flex_explorer-bitmapdata-perlin-noise</link>
		<comments>http://polygeek.com/1780_flex_explorer-bitmapdata-perlin-noise#comments</comments>
		<pubDate>Sun, 05 Apr 2009 15:10:06 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[bitmapData]]></category>
		<category><![CDATA[coding conventions]]></category>
		<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=1780</guid>
		<description><![CDATA[If you need to add some random noise to your BitmapData then you have two options: myBitmapData.perlinNoise which is sort of smooth gradiations of patterns. Sort of looks like a...]]></description>
			<content:encoded><![CDATA[<p>If you need to add some random noise to your BitmapData then you have two options:</p>
<ol>
<li><em>myBitmapData.perlinNoise</em> which is sort of smooth gradiations of patterns. Sort of looks like a nebula to me, or</li>
<li><em>myBitmapData.noise</em> which is much like static, just a bunch of randomly colored dots</li>
</ol>
<p>It is very easy to use each method but how changes in the parameters can change the output isn&#8217;t very obvious. So I created this Explorer because that&#8217;s what I do. I&#8217;m an Explorer of Actionscript. :)</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm__1780_ExploringNoise_137251868"
			class="flashmovie"
			width="440"
			height="725">
	<param name="movie" value="http://polygeek.com/flex/1780_ExploringNoise/_1780_ExploringNoise.swf" />
	<param name="wmode" value="normal" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://polygeek.com/flex/1780_ExploringNoise/_1780_ExploringNoise.swf"
			name="fm__1780_ExploringNoise_137251868"
			width="440"
			height="725">
		<param name="wmode" value="normal" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object></td>
</tr>
<tr>
<td align="center"><a href="http://polygeek.com/flex/1780_ExploringNoise/srcview/index.html">view source</a></td>
</tr>
</tbody>
</table>
<p><strong>And now&#8230;</strong><br />
Now you can go out and make some noise of your own. Maybe something a little more creative than this. Be sure to drop a comment below if you have anything you would like to share.</p>
<p><strong>Notes</strong><br />
The last parameter passed in the <em>perlinNoise</em> method is for an array of <em>offsets</em>. There&#8217;s no easy way to add user controls for editing that many possible arrays &#8211; one for each <em>octave</em>. Therefor I just left it out since the default is <em>null</em>. I also did a few experiments with adding an offset array behind the scenes without any user control but the change in visual appearance of the output was so small that I didn&#8217;t think it was worth the effort. It&#8217;s quite possible I wasn&#8217;t doing it right so you should play with it yourself.</p>
<p><strong>Coding conventions</strong><br />
In this Explorer I experimented with changing my coding conventions for giving IDs to components. I usually just give components a descriptive ID and I don&#8217;t think about the format that much. This time I placed the type of component at the beginning of the ID string followed by an underscore and then a descriptive name. I often get to a point in an method where I need to access a component and I have to remember the name. The Outline panel is helpful but I don&#8217;t use it as much as I should. With this convention all I have to do is type in <em>slid&#8230;</em> to get the code hinting for all of the slider components and then just pick it out of the lineup.</p>
<p>What do you think of this convention?</p>
<p><a href="http://polygeek.com/1780_flex_explorer-bitmapdata-perlin-noise" rel="bookmark">Explorer for BitmapData.perlinNoise and BitmapData.noise</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on April 5, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/1780_flex_explorer-bitmapdata-perlin-noise/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>localhost or not localhost, that is the question</title>
		<link>http://polygeek.com/1739_flex_localhost-or-not-localhost-that-is-the-question</link>
		<comments>http://polygeek.com/1739_flex_localhost-or-not-localhost-that-is-the-question#comments</comments>
		<pubDate>Sun, 22 Mar 2009 08:00:32 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[RemoteObject]]></category>
		<category><![CDATA[util]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=1739</guid>
		<description><![CDATA[How often to you have apps that need to change certain settings depending on whether you are publishing locally or deploying to a server? If you&#8217;re like me every time...]]></description>
			<content:encoded><![CDATA[<p>How often to you have apps that need to change certain settings depending on whether you are publishing locally or deploying to a server? If you&#8217;re like me every time you get ready to export for production you have to remember to change a few connection strings. But I forget all the time and end up exporting or worse forget altogether and the client emails me, &#8220;Hey, I can&#8217;t login anymore.&#8221;</p>
<p>Well, I&#8217;m tired as hell and I&#8217;m not going to take it anymore. I figured they had to be a better way so I started digging around in the <em>Application.application</em> properties and found the <em>url</em> property. I should have done this ages ago. In fact, I could swear that I saw a blog post about something like this months ago but I didn&#8217;t really pay attention and then couldn&#8217;t find it again. So if you blogged about this a few months ago thanks for planting the seed for me to get off my ass and start using this approach.</p>
<p>The very simple way to set this up is to simply ask:</p>
<p><code>if( Application.application.url.indexOf( &#039;localhost&#039; != -1 ) {<br />
</code><code> // this is the localhost</code><code><br />
} else {<br />
</code><code>// you are not on the localhost</code><br />
<code> }</code></p>
<p>With this you can set your RemoteObject connection properties depending on the location that the SWF is running from. Now you won&#8217;t have to change any settings when exporting.</p>
<p>If you&#8217;d like to take this a step further I wrote a static class to help. It will tell you if you&#8217;re on the <em>localhost</em> and much more. Look at the Flex app below to see all the properties.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm__1739_Localhost_790591507"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="http://polygeek.com/flex/1739_localhost/_1739_Localhost.swf" />
	<param name="wmode" value="normal" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://polygeek.com/flex/1739_localhost/_1739_Localhost.swf"
			name="fm__1739_Localhost_790591507"
			width="550"
			height="400">
		<param name="wmode" value="normal" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object></td>
</tr>
<tr>
<td align="center"><a href="http://polygeek.com/flex/1739_localhost/srcview/index.html">view source</a></td>
</tr>
</tbody>
</table>
<p><strong>Event Dispatcher</strong><br />
The version above is all ready to go. The only thing that it lacks is an event dispatcher at the end of the <em>init()</em> method. I use my own custom event dispatcher &#8211; <a href="http://polygeek.com/1383_flex_my-custom-event-manager-zion">Zion</a> &#8211; which works great for me but might not be your cup of tea. I&#8217;d suggest adding your own event dispatcher but if you want <a href="http://polygeek.com/flex/1739_localhost_Zion/srcview/index.html">here&#8217;s the same source code as above with my Zion class dispatching the event for you</a>.</p>
<p><a href="http://polygeek.com/1739_flex_localhost-or-not-localhost-that-is-the-question" rel="bookmark">localhost or not localhost, that is the question</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on March 22, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/1739_flex_localhost-or-not-localhost-that-is-the-question/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>BitmapData.draw</title>
		<link>http://polygeek.com/1713_flex_bitmapdatadraw-explorer</link>
		<comments>http://polygeek.com/1713_flex_bitmapdatadraw-explorer#comments</comments>
		<pubDate>Tue, 17 Mar 2009 14:40:59 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[bitmapData]]></category>
		<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=1713</guid>
		<description><![CDATA[The cornerstone to BitmapData is the draw method. That is one of the main ways to get pixels into your Bitmaps. Below is an explorer to allow you to play...]]></description>
			<content:encoded><![CDATA[<p>The cornerstone to BitmapData is the <em>draw</em> method. That is one of the main ways to get pixels into your Bitmaps. Below is an explorer to allow you to play around with selecting pixels from an image and see them drawn onto the surface below.</p>
<p>Dragging the mouse inputs the values for the Rectangle parameter. The radio buttons to the right allow you to control the BlendingMode and ColorTransformation parameters.</p>
<p>At the very bottom you can see text output of the exact values that went into drawing the pixels into the BitmapData.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm__1713_BitmapData_Draw_1446719312"
			class="flashmovie"
			width="550"
			height="720">
	<param name="movie" value="http://polygeek.com/flex/1713_BitmapData_Draw/_1713_BitmapData_Draw.swf" />
	<param name="wmode" value="normal" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://polygeek.com/flex/1713_BitmapData_Draw/_1713_BitmapData_Draw.swf"
			name="fm__1713_BitmapData_Draw_1446719312"
			width="550"
			height="720">
		<param name="wmode" value="normal" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object></td>
</tr>
<tr>
<td align="center"><a href="http://polygeek.com/flex/1713_BitmapData_Draw/srcview/index.html">view source</a></td>
</tr>
</tbody>
</table>
<p><a href="http://polygeek.com/1713_flex_bitmapdatadraw-explorer" rel="bookmark">BitmapData.draw</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on March 17, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/1713_flex_bitmapdatadraw-explorer/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>BitmapData Explorer</title>
		<link>http://polygeek.com/1709_flex_bitmapdata-explorer</link>
		<comments>http://polygeek.com/1709_flex_bitmapdata-explorer#comments</comments>
		<pubDate>Thu, 12 Mar 2009 08:00:16 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[bitmapData]]></category>
		<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=1709</guid>
		<description><![CDATA[I&#8217;m revisiting my Actionscript Bible and running through the chapter on Drawing Bitmap Graphics Programmatically just to shore up some gaps in my knowledge.  You can expect to see a...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m revisiting my Actionscript Bible and running through the chapter on <em>Drawing Bitmap Graphics Programmatically</em> just to shore up some gaps in my knowledge.  You can expect to see a lot of rudimentary examples on Bitmaps for the next few days. You know what they say, &#8220;Practice makes perfect.&#8221;</p>
<p>It can&#8217;t get more basic than the Bitmap constructor. Here you can see how changing the <em>pixelSnapping </em>and <em>smoothing</em> both effect visual representation of the BitmapData.</p>
<p><em>pixelSnapping </em>and <em>smoothing </em>don&#8217;t matter much if an image just sits in place and isn&#8217;t moved, resized or rotated. But if you do any of those you&#8217;ll see a big difference.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm__1709_BitmapDataExplorer_45825842"
			class="flashmovie"
			width="550"
			height="500">
	<param name="movie" value="http://polygeek.com/flex/1709_BitmapDataExplorer/_1709_BitmapDataExplorer.swf" />
	<param name="wmode" value="normal" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://polygeek.com/flex/1709_BitmapDataExplorer/_1709_BitmapDataExplorer.swf"
			name="fm__1709_BitmapDataExplorer_45825842"
			width="550"
			height="500">
		<param name="wmode" value="normal" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object></td>
</tr>
<tr>
<td align="center"><a href="http://polygeek.com/flex/1709_BitmapDataExplorer/srcview/index.html">view source</a></td>
</tr>
</tbody>
</table>
<p><strong>No code hinting</strong><br />
One thing I noticed in creating this example is that the code hinting and refactoring do not work on the class names of the embeded assets. Maybe we&#8217;ll get that with Gumbo.</p>
<p><a href="http://polygeek.com/1709_flex_bitmapdata-explorer" rel="bookmark">BitmapData Explorer</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on March 12, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/1709_flex_bitmapdata-explorer/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using unique background colors for each row of a Datagrid</title>
		<link>http://polygeek.com/1696_flex_unique-background-colors-datagrid</link>
		<comments>http://polygeek.com/1696_flex_unique-background-colors-datagrid#comments</comments>
		<pubDate>Tue, 10 Mar 2009 08:00:07 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[DataGrid]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=1696</guid>
		<description><![CDATA[Don&#8217;t ask how I got started on this but I got interested in making a Datagrid with unique colors for each row. As an example I used the team colors...]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t ask how I got started on this but I got interested in making a Datagrid with unique colors for each row. As an example I used the team colors for all the NFL teams.</p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm__1675_Datagrid_teamColors_960530471"
			class="flashmovie"
			width="450"
			height="450">
	<param name="movie" value="http://polygeek.com/flex/1675_Datagrid_teamColors/_1675_Datagrid_teamColors.swf" />
	<param name="wmode" value="normal" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://polygeek.com/flex/1675_Datagrid_teamColors/_1675_Datagrid_teamColors.swf"
			name="fm__1675_Datagrid_teamColors_960530471"
			width="450"
			height="450">
		<param name="wmode" value="normal" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object></td>
</tr>
<tr>
<td align="center"><a href="http://polygeek.com/flex/1675_Datagrid_teamColors/srcview/index.html">view source</a></td>
</tr>
</tbody>
</table>
<p>Here&#8217;s the gist of how to apply this technique. You can check out the <a href="http://polygeek.com/flex/1675_Datagrid_teamColors/srcview/index.html">source</a> to see the whole story.</p>
<p>First you need to listen to the <em>headerRelease</em> event on the datagrid. In your handler you can sort the <em>ArrayCollection</em> ( _<em>nflTeams</em> ) that acts as the <em>dataProvider</em>. Once you have _<em>nflTeams</em> sorted you loop through it and create an array of the <em>teamColors</em>. The _<em>nflTeams </em>AC has four colors per team. I&#8217;m using the first color [0] as the background and the second [1] as the font-color.</p>
<p>The background color gets applied as a style using the <em>setStyle</em> method on the Datagrid:</p>
<p><code>nflTeamsDG.setStyle( &amp;#039;alternatingItemColors&amp;#039;, colors );</code></p>
<p>The font color is applied in the custom renderer for each column since it is part of the <em>data</em> property of each renderer:</p>
<p><code>private function onDataChange():void {<br />
var fontColor:String = this.data.teamColors.split( &amp;#039;,&amp;#039; )[1];<br />
labelLink.setStyle( &amp;#039;color&amp;#039;, fontColor );<br />
}</code></p>
<p>That&#8217;s pretty much it. There isn&#8217;t much source code to wade through. Unfortunately I worked on this yesterday and didn&#8217;t bother cleaning it up this morning before posting. If you notice an mistakes that&#8217;s why. ( Note to self: always clean your code before going to bed. )</p>
<p><a href="http://polygeek.com/1696_flex_unique-background-colors-datagrid" rel="bookmark">Using unique background colors for each row of a Datagrid</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on March 10, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/1696_flex_unique-background-colors-datagrid/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>polyGeek.com undergoing Flex assimilation</title>
		<link>http://polygeek.com/1686_flex_polygeekcom-undergoing-flex-assimilation</link>
		<comments>http://polygeek.com/1686_flex_polygeekcom-undergoing-flex-assimilation#comments</comments>
		<pubDate>Mon, 09 Mar 2009 08:00:54 +0000</pubDate>
		<dc:creator>polygeek</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[drawingAPI]]></category>
		<category><![CDATA[unicode]]></category>
		<category><![CDATA[Zongy]]></category>

		<guid isPermaLink="false">http://polygeek.com/?p=1686</guid>
		<description><![CDATA[All I wanted to do is replace the existing banner at the top of my blog with something that looked exactly the same but used my Zongy class for the...]]></description>
			<content:encoded><![CDATA[<p>All I wanted to do is replace the existing banner at the top of my blog with something that looked exactly the same but used my Zongy class for the icons under <em>polyGeek.com</em>. Now you can wave your mouse back and forth across the icons and get the cool zongy effect.</p>
<p>Here&#8217;s a look at the code for one of the icons:</p>
<p><code>.icons {<br />
Actionscript:	Embed( &#039;assets/icons/Actionscript.png&#039; );<br />
AIR:			Embed( &#039;assets/icons/AIR.png&#039; );<br />
AMF:			Embed( &#039;assets/icons/AMFPHP.png&#039; );<br />
Flash:			Embed( &#039;assets/icons/Flash.png&#039; );<br />
Flex:			Embed( &#039;assets/icons/Flex.png&#039; );<br />
FMS:			Embed( &#039;assets/icons/FlashMediaServer.png&#039; );<br />
Photoshop:		Embed( &#039;assets/icons/Photoshop.png&#039; );<br />
}</code></p>
<p><code>// declare the var as a local </code><br />
<code> private var _zongyOverEffect:Zongy;</code><br />
<code>private var _zongyOverEffect:Zongy;</code></p>
<p><code> private function init():void {</code><br />
<code>//initialize the effect/class</code><br />
<code> _zongyOverEffect = new Zongy( 1.02, 1.2, 250 );</code><br />
<code> }</code></p>
<p><code> private function zongyOver( e:Event ):void {</code><br />
<code> _zongyOverEffect.start( e.currentTarget as UIComponent );</code><br />
<code> }</code></p>
<p><code> private function getURL( e:Event, s:String ):void {</code><br />
<code> _zongyClickEffect.start( e.currentTarget as UIComponent );</code><br />
<code> Tron.openLink( s );</code><br />
<code> }</code></p>
<p><code>&lt;mx:Image source="{ StyleManager.getStyleDeclaration('.icons').getStyle( 'Flex' ) }"<br />
click="getURL( event, 'http://polygeek.com/tag/flex' );"<br />
rollOver="zongyOver( event );"<br />
useHandCursor="true"<br />
mouseChildren="false"<br />
buttonMode="true" /&gt;<!--formatted--></code></p>
<p>The first thing you&#8217;ll notice is the source isn&#8217;t a path to a file. Instead  I created one style .<em>icons </em>to hold all the icon paths. And then use the <em>StyleManager </em>to set the specific value of each Image. I&#8217;ve found that it&#8217;s <a href="http://polygeek.com/1532_flex_putting-all-your-icons-in-one-basket">a handy way of manage assets</a>. ( Thanks to Juan Sanchez and Any McIntosh <a href="http://www.amazon.com/Creating-Visual-Experiences-Flex-3-0/dp/B001FA0MLQ/ref=sr_1_3?ie=UTF8&amp;s=books&amp;qid=1228600060&amp;sr=8-3"><em>Creating Visual Experiences with Flex 3.0</em></a> for the tip. )</p>
<p>The getURL method applies the _<em>zongyClickEffect </em>and then opens the link using a static method from my <em>Tron</em> class to open a URL. ( <em>Tron </em>is where I keep my generic utility functions that I use on most every project. )</p>
<p>Of course while I&#8217;m at it I might as well apply <em>Zongy </em>to the page nav as well. Easy enough.</p>
<p>Then I started messing around and drew my polyGeek logo using the drawing API &#8211; more on that later. So now the logo is created with code and is used for the mask of a gradient so that I get the same look as before. Add a drop shadow and call it done.</p>
<p>The hardest thing was figuring out how to rotate a gradient drawn with <em>graphics.beginGradientFill</em>. It&#8217;s simple to do just not very obvious.</p>
<p><code>var matrix:Matrix = new Matrix();</code><br />
<code>matrix.createGradientBox( 450, 50, Math.PI/2, 0, 0 );</code></p>
<p><code>polyGeekcomBG.graphics.beginGradientFill( 	GradientType.LINEAR,<br />
[ 0xFFFFFF, 0x000000 ],<br />
[ 1, 1 ], [ 1, 255 ],<br />
matrix );</code></p>
<p><code>polyGeekcomBG.graphics.drawRect( 0, 0, 450, 50 );</code></p>
<p>I created a <a href="http://polygeek.com/1676_flex_creategradientbox-explorer">createGradientBox explorer</a> just to see exactly how changing the parameters effected the gradient.</p>
<p>But what about the letters: <em>polyGeek.com</em>? I can&#8217;t leave that as a bitmap can I? Nope, so I created a label and used it as a mask, blah, blah, blah. But the problem is that I need to use Arial Black as the font or it won&#8217;t look exactly right. In that case I&#8217;d have to embed the font but only a few characters. So I created an <a href="http://polygeek.com/1674_flex_using-unicode-ranges-in-flex-css">app for making @font-face declarations with specific only characters embeded</a>. And of course I did the same thing for the <em>mi coda, su code</em> which uses the Lynch font which isn&#8217;t likely to be on many computers out there.</p>
<p>Flex apps have now assimilated the banner and comment submission here on polyGeek.com. You will become one with the Flex. Resistance is futile. :-)</p>
<p><a href="http://polygeek.com/1686_flex_polygeekcom-undergoing-flex-assimilation" rel="bookmark">polyGeek.com undergoing Flex assimilation</a> originally appeared on <a href="http://polygeek.com">polyGeek.com</a> on March 9, 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://polygeek.com/1686_flex_polygeekcom-undergoing-flex-assimilation/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  polygeek.com/tag/actionscript-3/feed ) in 0.71786 seconds, on May 21st, 2012 at 10:28 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 21st, 2012 at 11:28 am UTC -->
