<?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"
	>

<channel>
	<title>Ryan Bosinger</title>
	<atom:link href="http://ryanbosinger.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://ryanbosinger.com/blog</link>
	<description>things I learn, as I learn them</description>
	<pubDate>Wed, 12 Nov 2008 18:07:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Wordpress: Speed up your blog with super caching!</title>
		<link>http://ryanbosinger.com/blog/2008/wordpress-speed-up-your-blog-with-super-caching/</link>
		<comments>http://ryanbosinger.com/blog/2008/wordpress-speed-up-your-blog-with-super-caching/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 18:06:52 +0000</pubDate>
		<dc:creator>rbosinger</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://ryanbosinger.com/blog/?p=62</guid>
		<description><![CDATA[I just installed WP Super Cache and I have to say I wish I had done this earlier!

Before I installed this I noticed that sometimes my blog would timeout and send back only a white page.  I thought it was likely because I am on shared hosting and sometimes the PHP or MySQL just [...]]]></description>
			<content:encoded><![CDATA[<p>I just installed <a href="http://wordpress.org/extend/plugins/wp-super-cache/" target="_blank">WP Super Cache</a> and I have to say I wish I had done this earlier!</p>

<p>Before I installed this I noticed that sometimes my blog would timeout and send back only a white page.  I thought it was likely because I am on shared hosting and sometimes the PHP or MySQL just wasn&#8217;t ready to kick in fast enough (because it never it happens with HTML pages and it seemed like once I hit the first page everything would be &#8220;warmed up&#8221; and this blog would run normally).</p>

<p>I also been meaning to figure out how to get gzip content encoding on my pages, although I never really tried.</p>

<span id="more-62"></span>

<p>Anyway I installed <a href="http://wordpress.org/extend/plugins/wp-super-cache/" target="_blank">WP Super Cache</a> and it&#8217;s just great.  If a post isn&#8217;t updated, or doesn&#8217;t receive any new comments, then WP Super Cache sends out a cached version and to my understanding should be saving my account a lot of processor cycles and db requests.  I don&#8217;t post a lot, and I don&#8217;t get many comments on my posts so I see absolutely no reason not to have this on.  Also, now the cached versions of my pages are gzipped.</p>

<p>Here&#8217;s a screenshot of my Firebug console the first time I hit my post <a href="/blog/2008/flashactionscript-innaccurate-math-results/" target="_blank">&#8220;Flash/Actionscript: Innaccurate Math Results&#8221;</a> just after installing WP Super Cache:</p>

<p>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/11/screenhunter_01-nov-12-1250.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/11/screenhunter_01-nov-12-1250.gif" alt="" title="screenhunter_01-nov-12-1250" class="alignnone size-full wp-image-63" /></a>
</p>

<p>and here&#8217;s a screenshot <em>after</em>&#8230; now it&#8217;s gzipped, so it weighs in at a lot less and takes less server-side thought so it comes up nice and quick:</p>

<p><strong>Geez&#8230; I cut it off in the screen shot, but the page (minus images/css) went from about 25kb to 6kb.</strong></p>

<p>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/11/screenhunter_02-nov-12-1251.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/11/screenhunter_02-nov-12-1251.gif" alt="" title="screenhunter_02-nov-12-1251" class="alignnone size-full wp-image-64" /></a>
</p>

<p>I know this is nothing new to most people and that there are plenty of better articles on this subject.  I just get excited when things work nicely.</p>]]></content:encoded>
			<wfw:commentRss>http://ryanbosinger.com/blog/2008/wordpress-speed-up-your-blog-with-super-caching/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flash 9: Text fields and buttons don&#8217;t show up in browser</title>
		<link>http://ryanbosinger.com/blog/2008/flash-9-text-fields-and-buttons-dont-show-up-in-browser/</link>
		<comments>http://ryanbosinger.com/blog/2008/flash-9-text-fields-and-buttons-dont-show-up-in-browser/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 14:51:49 +0000</pubDate>
		<dc:creator>rbosinger</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

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

		<guid isPermaLink="false">http://ryanbosinger.com/blog/?p=58</guid>
		<description><![CDATA[    
        
            
                Problem:
            
   [...]]]></description>
			<content:encoded><![CDATA[    <div class="problem-solution">
        <p class="problem">
            <strong>
                Problem:
            </strong>
        </p> 
        <blockquote>
            You publish your SWF from the Flash CS3 IDE and everything looks fine.  You, or someone else checks out the SWF in a browser and although everything kind of works, certain elements like text fields and component buttons aren&#8217;t rendering properly!
        </blockquote> 
        
        <p class="solution">
            <strong>
                Solution:
            </strong>
        </p>
        <blockquote>
            Sometimes certain revisions of the Flash 9 player behave differently than expected, but there is a way you can look into it.  Read on&#8230;
        </blockquote>
    </div>
<span id="more-58"></span>


<p>I actually just tried to recreate this, and I can&#8217;t.  All I know, is that on two particular occasions while working on moderate sized flash projects certain revisions of the flash player would fail to render some things properly (but not every time).  This kind of thing is very frustrating, and if you think it might be happening to you, this is what I suggest:</p>

<ul>
<li>Go here: <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14266">http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14266</a> and download the Flash Player 9 archive file (I had this problem with FP9).</li>
<li>Go here: <a href="http://www.adobe.com/support/flashplayer/downloads.html">http://www.adobe.com/support/flashplayer/downloads.html</a> and download the Flash uninstaller.</li>
<li>Uninstall Flash, install a different revision, and test your movie (in the browser).  In my case, revision 47 caused this problem, and sure enough anyone testing the movie that saw this problem had revision 47.  I haven&#8217;t been able to recreate this error by creating a new flash movie using components and viewing it with flash player rev 47, but there must have been some combination of things that the particular revision didn&#8217;t like.</li>
<li>If you find a revision that&#8217;s giving you problems, make sure to check for a more current one in your flash embed code.</li>
</ul>

<p>This is a screenshot of the unzipped folder containing all the different versions of Flash 9.  The ones ending in &#8220;win&#8221; would be for Firefox and Netscape, and the ones ending in &#8220;winax&#8221; are for IE (ActiveX).  There&#8217;s some linux and mac ones in there too.  I believe &#8220;SA&#8221; stands for standalone.  Play around.</p>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/10/screenhunter_02-oct-01-1045.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/10/screenhunter_02-oct-01-1045.gif" alt="Screenshot of Flash 9 archives" title="screenhunter_02-oct-01-1045" width="500" height="691" class="alignnone size-full wp-image-59" /></a>

]]></content:encoded>
			<wfw:commentRss>http://ryanbosinger.com/blog/2008/flash-9-text-fields-and-buttons-dont-show-up-in-browser/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flash Animation: Character Shading</title>
		<link>http://ryanbosinger.com/blog/2008/flash-animation-character-shading/</link>
		<comments>http://ryanbosinger.com/blog/2008/flash-animation-character-shading/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 17:58:53 +0000</pubDate>
		<dc:creator>rbosinger</dc:creator>
		
		<category><![CDATA[Animation]]></category>

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

		<guid isPermaLink="false">http://ryanbosinger.com/blog/?p=52</guid>
		<description><![CDATA[ Adding some shading to characters and objects is a good way to add some depth to your flash animations. The following tip may be an obvious one, but if it&#8217;s new to you it may be one of the handiest tips you ever get.


 1. Draw, or open up something you want to shade. [...]]]></description>
			<content:encoded><![CDATA[ <p>Adding some shading to characters and objects is a good way to add some depth to your flash animations. The following tip may be an obvious one, but if it&#8217;s new to you it may be one of the handiest tips you ever get.</p>

<span id="more-52"></span>
 <p>1. Draw, or open up something you want to shade. In this case, I have Rick&#8217;s head from <a href="http://www.vote4oz.com">Vote4Oz</a></p>
 
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/09/shading_rick.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/09/shading_rick.gif" alt="" title="shading_rick" width="255" height="220" class="aligncenter size-full wp-image-56" /></a>

 <p>2. Using the <strong>eyedropper tool (I)</strong>, select the main color. </p>
 <p>3. Open up the color picker, and slide the bar on the right down slightly so that you end up with a slightly darker shade of the color.</p>
 <a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/09/shading_colorpalette.png'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/09/shading_colorpalette.png" alt="" title="shading_colorpalette" width="455" height="335" class="aligncenter size-full wp-image-54" /></a>

 <p>4. Select the fill of your object </p>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/09/shading_rickselected.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/09/shading_rickselected.gif" alt="" title="shading_rickselected" width="255" height="220" class="aligncenter size-full wp-image-57" /></a>

<div class="google_ads_01">
<script type="text/javascript"><!--
google_ad_client = "pub-1962502741893893";
/* 468x60, created 5/27/08 */
google_ad_slot = "8820555819";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

 <p>5. Now, choose the <strong>brush tool (b)</strong>, and in the <em>options</em> portion of the toolbar, select <strong>Paint Selection </strong></p>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/09/shading_paintselection.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/09/shading_paintselection.gif" alt="" title="shading_paintselection" width="291" height="292" class="aligncenter size-full wp-image-55" /></a>

 <p>6. Run your brush over the area you want shaded, only what you have selected will be affected by the brush, so go nuts.</p>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/09/shading_rickshaded.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/09/shading_rickshaded.gif" alt="" title="shading_rickshaded" width="255" height="220" class="aligncenter size-full wp-image-53" /></a>
 <p>And there ya go. She&#8217;s a beaute.</p>

 <p><strong>Note:</strong> If you don&#8217;t already, using the keyboard to switch between tools will save you tons of time in Flash. With this technique, toggling between the brush tool and the selection tool using<strong> B</strong> and <strong>V</strong> on the keyboard will make you an efficient shading machine. </p>

<div class="google_ads_01">
<script type="text/javascript"><!--
google_ad_client = "pub-1962502741893893";
/* 468x60, created 5/27/08 */
google_ad_slot = "8820555819";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ryanbosinger.com/blog/2008/flash-animation-character-shading/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Subway&#8217;s at Night</title>
		<link>http://ryanbosinger.com/blog/2008/subways-at-night/</link>
		<comments>http://ryanbosinger.com/blog/2008/subways-at-night/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 17:43:56 +0000</pubDate>
		<dc:creator>rbosinger</dc:creator>
		
		<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://ryanbosinger.com/blog/?p=50</guid>
		<description><![CDATA[



I smell oranges.
This can only mean one thing.


Tigers.
Large cats that hunt by night.
It worries me, but I can&#8217;t do anything.


I am a bird.

]]></description>
			<content:encoded><![CDATA[<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/09/thumbs_up.jpg'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/09/thumbs_up-300x197.jpg" alt="" title="thumbs_up" width="300" height="197" class="aligncenter size-medium wp-image-51" /></a>

<div style="text-align: center;">
<p>
I smell oranges.<br/>
This can only mean one thing.
</p>
<p>
<strong>Tigers.</strong><br/>
Large cats that hunt by night.<br/>
It worries me, but I can&#8217;t do anything.

<p>
<strong>I am a bird.</strong>
</p>
</div>]]></content:encoded>
			<wfw:commentRss>http://ryanbosinger.com/blog/2008/subways-at-night/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Javascript: Get variables from querystring</title>
		<link>http://ryanbosinger.com/blog/2008/javascript-get-variables-from-querystring/</link>
		<comments>http://ryanbosinger.com/blog/2008/javascript-get-variables-from-querystring/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 17:31:55 +0000</pubDate>
		<dc:creator>rbosinger</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://ryanbosinger.com/blog/?p=40</guid>
		<description><![CDATA[


        
            
                Problem:
            
       [...]]]></description>
			<content:encoded><![CDATA[<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/08/screenhunter_02-aug-06-1651.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/08/screenhunter_02-aug-06-1651.gif" alt="" title="Querystring" width="375" height="156" class="aligncenter size-full wp-image-41" /></a>

<div class="problem-solution">
        <p class="problem">
            <strong>
                Problem:
            </strong>
        </p>
        <blockquote>
            You need to grab some information from the querystring of a URL using only javascript.
        </blockquote>
       
        <p class="solution">
            <strong>
                Solution:
            </strong>
        </p>
        <blockquote>
            Use some code I found!
        </blockquote>
    </div>
<span id="more-40"></span>
<p>I found this code:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #009966; font-style: italic;">/* Client-side access to querystring name=value pairs
	Version 1.2.3
	22 Jun 2005
	Adam Vandenberg
*/</span>
<span style="color: #003366; font-weight: bold;">function</span> Querystring<span style="color: #009900;">&#40;</span>qs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// optionally pass a querystring to parse</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">params</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Object<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">get</span><span style="color: #339933;">=</span>Querystring_get
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>qs <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		qs<span style="color: #339933;">=</span>location.<span style="color: #006600;">search</span>.<span style="color: #006600;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span>location.<span style="color: #006600;">search</span>.<span style="color: #006600;">length</span><span style="color: #009900;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>qs.<span style="color: #006600;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Turn &lt;plus&gt; back to &lt;space&gt;</span>
<span style="color: #006600; font-style: italic;">// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1</span>
	qs <span style="color: #339933;">=</span> qs.<span style="color: #006600;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\+/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">' '</span><span style="color: #009900;">&#41;</span>
	<span style="color: #003366; font-weight: bold;">var</span> args <span style="color: #339933;">=</span> qs.<span style="color: #006600;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&amp;'</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// parse out name/value pairs separated via &amp;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// split out each name=value pair</span>
	<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>args.<span style="color: #006600;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> value<span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> pair <span style="color: #339933;">=</span> args<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006600;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'='</span><span style="color: #009900;">&#41;</span>
		<span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066;">name</span> <span style="color: #339933;">=</span> unescape<span style="color: #009900;">&#40;</span>pair<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>pair.<span style="color: #006600;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span>
			value <span style="color: #339933;">=</span> unescape<span style="color: #009900;">&#40;</span>pair<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000066; font-weight: bold;">else</span>
			value <span style="color: #339933;">=</span> <span style="color: #000066;">name</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">params</span><span style="color: #009900;">&#91;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> value
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> Querystring_get<span style="color: #009900;">&#40;</span>key<span style="color: #339933;">,</span> default_<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// This silly looking line changes UNDEFINED to NULL</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>default_ <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> default_ <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> value<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">params</span><span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>value<span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> value<span style="color: #339933;">=</span>default_<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">return</span> value
<span style="color: #009900;">&#125;</span></pre></div></div>




<p>
So throw that in your page, and then call that sucker like this:
</p>


<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #006600; font-style: italic;">// Parse the current page's querystring</span>
<span style="color: #003366; font-weight: bold;">var</span> qs <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Querystring<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>




<p>
And then just go right on ahead and populate some variables with some query string variables:
</p>


<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> v1 <span style="color: #339933;">=</span> qs2.<span style="color: #006600;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;name1&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #003366; font-weight: bold;">var</span> v3 <span style="color: #339933;">=</span> qs2.<span style="color: #006600;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;name3&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;default value&quot;</span><span style="color: #009900;">&#41;</span></pre></div></div>



<div class="google_ads_01">
<script type="text/javascript"><!--
google_ad_client = "pub-1962502741893893";
/* 468x60, created 5/27/08 */
google_ad_slot = "8820555819";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p>
And use that information for whatever you needed it for in the first place.  Is nice?
</p>]]></content:encoded>
			<wfw:commentRss>http://ryanbosinger.com/blog/2008/javascript-get-variables-from-querystring/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Save images from Flash to your server using ASP.NET webservices</title>
		<link>http://ryanbosinger.com/blog/2008/saving-images-with-net/</link>
		<comments>http://ryanbosinger.com/blog/2008/saving-images-with-net/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 18:29:38 +0000</pubDate>
		<dc:creator>rbosinger</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

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

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

		<guid isPermaLink="false">http://ryanbosinger.com/blog/?p=42</guid>
		<description><![CDATA[    
        
            
                Problem:
            
   [...]]]></description>
			<content:encoded><![CDATA[    <div class="problem-solution">
        <p class="problem">
            <strong>
                Problem:
            </strong>
        </p> 
        <blockquote>
You want to save an image from Flash to a server using Actionscript 3.0 and ASP.NET.
        </blockquote> 
        
        <p class="solution">
            <strong>
                Solution:
            </strong>
        </p>
        <blockquote>
            Read this article!
        </blockquote>
    </div>
<span id="more-42"></span>
<p>
<strong>Note: </strong>
This blog is hosted on a Linux based server that uses PHP, therefore I can&#8217;t show you a working example directly on this blog (unless anyone with a Windows based hosting account would like to host one for me?).  However, I can assure you this <em>does</em> work and you can download the files here and try it for yourself.
</p>

<p class="download">
<a href="/blog/downloads/FlashBitmapSave.zip">
Download &#8220;FlashBitmapSave.zip&#8221;
</a>
<p>
<div class="google_ads_01">
<script type="text/javascript"><!--
google_ad_client = "pub-1962502741893893";
/* 468x60, created 5/27/08 */
google_ad_slot = "8820555819";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<h3>Get this thing running</h3>
<span><em>&#8230;or just take a look at the code/explanation&#8230;</em></span><br/>
<p>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/09/screenhunter_06-sep-18-1021.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/09/screenhunter_06-sep-18-1021.gif" alt="" title="screenhunter_06-sep-18-1021" width="429" height="86" class="alignnone size-full wp-image-45" /></a>
</p>

<p>Open the downloaded website in Visual Studio 2008 or Visual Web Developer Express 2008.  2005 versions should be fine as well.</p>

<p>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/09/screenhunter_07-sep-18-1021.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/09/screenhunter_07-sep-18-1021.gif" alt="" title="screenhunter_07-sep-18-1021" class="alignnone size-full wp-image-44" /></a>
</p>

<p>Run it.</p>

<p>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/09/screenhunter_08-sep-18-1046.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/09/screenhunter_08-sep-18-1046.gif" alt="" title="screenhunter_08-sep-18-1046" class="alignnone size-full wp-image-46" /></a>
</p>

<p>The default page should come up in your browser.  You&#8217;ll see my example Flash app.  Draw a picture and click &#8220;save to server&#8221; to - of course - save a JPEG version of your drawing from Flash.</p>

<p><strong>Note:</strong> Saved JPEGs will be assigned a random GUID as a filename and saved directly to the root of your C: drive.  You can modify the path in App_Code/Service.vb.  If you need to know more about that aspect of it, I would continue reading the rest of this post.</p>

<p><strong>If the flash app comes up but gives you the message &#8220;<em>webservice failed to initialize&#8230;</em>&#8221; then:</strong></p>

<p>Click on the root of the project in your solution explorer.</p>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/09/screenhunter_09-sep-18-1648.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/09/screenhunter_09-sep-18-1648.gif" alt="" title="screenhunter_09-sep-18-1648" class="alignnone size-full wp-image-47" /></a>
<br/><br/>
<p>In the properties panel below, take a look at your Virtual Path.</p>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/09/screenhunter_10-sep-18-1649.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/09/screenhunter_10-sep-18-1649.gif" alt="" title="screenhunter_10-sep-18-1649" class="alignnone size-full wp-image-48" /></a>
<br/><br/>
<p>It should only have a &#8220;/&#8221; in it.</p>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/09/screenhunter_11-sep-18-1649.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/09/screenhunter_11-sep-18-1649.gif" alt="" title="screenhunter_11-sep-18-1649"  class="alignnone size-full wp-image-49" /></a>
<br/><br/>
<p>Try it again.</p>

<div class="google_ads_01">
<script type="text/javascript"><!--
google_ad_client = "pub-1962502741893893";
/* 468x60, created 5/27/08 */
google_ad_slot = "8820555819";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

<h3>The process</h3>

<ul>
<li>Take a BitmapData object in Flash, and convert it to a ByteArray object using the JPGEncoder class (or, in my example, the Asynchronous JPEG Encoder class).</li>
<li>Take that ByteArray and Base64 encode it.  We do this so that Actionscript and the .NET back-end will be speaking the same language.  If we were using Flex and remoting software like WebORB, this type of conversion would likely happen automatically when sending or receiving a ByteArray object to/from Actionscript or .NET.  But for this one-off scenario, doing it ourselves isn&#8217;t a big deal.</li>
<li>Use a third party AS3 webservice class to send the encoded ByteArray to our .NET webservice.</li>
<li>Our .NET webservice unencodes the ByteArray into its own form of ByteArray, creates a random file name using a GUID, and then saves the raw binary information to a .jpg file.</li>
</ul>

<h3>Some extra stuff you will need</h3>

<ul>
   <li>
		<strong>
			<a href="http://dynamicflash.com/goodies/base64/">
				Base64 encoder/decoder class
			</a>
		</strong>
		<br/>
		This class from Dynamic Flash will be used to encode our ByteArray to Base64.
   </li>
   <li>
		<strong>
			<a href="http://www.wellconsidered.be/blog/as3-webservice-component/">
				WebService component
			</a>
		</strong>
		<br/>
		Adobe left the WebService classes out of Flash CS3.  wellconsidered made their own.  This is how we&#8217;ll be communicating with the server.  This download is available as a .swc and needs to be dropped
		into your .fla to work.
   </li>
   <li>
		<strong>
			<a href="http://blog.paranoidferret.com/index.php/2007/12/11/flex-tutorial-an-asynchronous-jpeg-encoder/">
				Asynchronous JPEG Encoder
			</a>
		</strong>
		<br/>
		In my example I use the Asynchronous JPEG Encoder.  You could also use Adobe&#8217;s regular JPEG encode available in the <a href="http://code.google.com/p/as3corelib/">AS3 CoreLib</a>.
   </li>
</ul>

<div class="google_ads_01">
<script type="text/javascript"><!--
google_ad_client = "pub-1962502741893893";
/* 468x60, created 5/27/08 */
google_ad_slot = "8820555819";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

<h3>The Code</h3>

<p>
Now I&#8217;m just going to post the code.  I did my best to comment the code thoroughly, but I&#8217;m not going to go through it line by line in this post.  I&#8217;ll assume that if you&#8217;re in need of saving bitmap information from flash to a server using .NET, that most of what&#8217;s going on you already understand and maybe just needed an example to help you along.  So here ya go!
</p>

<h4>The actionscript 3.0 code:</h4>


<div class="wp_syntax"><div class="code"><pre class="actionscript3"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Bitmap</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">BitmapData</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.text</span>.<span style="color: #004993;">TextField</span>;
        <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #000000; font-weight: bold;">*</span>;
        <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #000000; font-weight: bold;">*</span>;
        <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">MovieClip</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span>.<span style="color: #004993;">ByteArray</span>;
&nbsp;
	<span style="color: #009900;">// We'll be sending a ByteArray encoded as Base64, and then decoding it on the .NET side.</span>
	<span style="color: #009900;">// http://dynamicflash.com/goodies/base64/</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.dynamicflash.util.Base64;
&nbsp;
	<span style="color: #009900;">// be.wellconsidered classes give us an easy means to communicate with webservices.</span>
	<span style="color: #009900;">// The extension needs to be installed and the component then dropped into your .FLA.</span>
	<span style="color: #009900;">// You'll see a component called &quot;Service&quot; in the library of the example .FLA.</span>
	<span style="color: #009900;">// http://www.wellconsidered.be/blog/as3-webservice-component/</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> be.wellconsidered.services.WebService;
	<span style="color: #0033ff; font-weight: bold;">import</span> be.wellconsidered.services.Operation;
	<span style="color: #0033ff; font-weight: bold;">import</span> be.wellconsidered.services.events.OperationEvent;
	<span style="color: #0033ff; font-weight: bold;">import</span> be.wellconsidered.services.events.WebServiceEvent;
&nbsp;
	<span style="color: #009900;">// com.pfp includes classes for the Asynchronous JPEG encoder.  There is also a JPEG encoder</span>
	<span style="color: #009900;">// in Adobe's CoreLib (http://code.google.com/p/as3corelib/), but because this one is asynchronous it allows to </span>
	<span style="color: #009900;">// monitor the rendering of the jpeg and therefore create a progress bar.  It is also essential when rendering larger</span>
	<span style="color: #009900;">// bitmaps, otherwise Flash could time out during the processing.</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.pfp.events.<span style="color: #000000; font-weight: bold;">*</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.pfp.utils.<span style="color: #000000; font-weight: bold;">*</span>;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> FlashBitmapSave extends <span style="color: #004993;">MovieClip</span>
    <span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">// we create our WebService object.  Remember to include &quot;?wsdl&quot; in the URL.</span>
	<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> wsMainService<span style="color: #000000; font-weight: bold;">:</span>WebService = <span style="color: #0033ff; font-weight: bold;">new</span> WebService<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;/Service.asmx?wsdl&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
                <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> FlashBitmapSave<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                        mcDrawingBoard.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_DOWN</span>, mcDrawingBoard_MouseDown<span style="color: #000000;">&#41;</span>;
			btnSaveToServer.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">CLICK</span>, btnSaveToServer_Click<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// the listener on our webservice will let us know if there's a problem with the webservice,</span>
			<span style="color: #009900;">// if the url is wrong, if the service is down, etc.</span>
			wsMainService.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>WebServiceEvent.INITFAILED, wsMainService_InitFailed<span style="color: #000000;">&#41;</span>;
                <span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900;">// **** functions for the drawing pad **** //</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> mcDrawingBoard_MouseDown<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</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>
			mcDrawingBoard.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_MOVE</span>, mcDrawingBoard_MouseMove<span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_UP</span>, stage_MouseUp<span style="color: #000000;">&#41;</span>;
			mcDrawingBoard.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span>mcDrawingBoard.<span style="color: #004993;">mouseX</span>, mcDrawingBoard.<span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> mcDrawingBoard_MouseMove<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</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>
			mcDrawingBoard.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">1</span>, 0x000000<span style="color: #000000;">&#41;</span>;
			mcDrawingBoard.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span>mcDrawingBoard.<span style="color: #004993;">mouseX</span>, mcDrawingBoard.<span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> stage_MouseUp<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</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>
			mcDrawingBoard.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">MOUSE_MOVE</span>, mcDrawingBoard_MouseMove<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900;">// ************************************** //</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> btnSaveToServer_Click<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</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>
			<span style="color: #6699cc; font-weight: bold;">var</span> bmdSnapshot<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>mcDrawingBoard.<span style="color: #004993;">width</span>, mcDrawingBoard.<span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// take a snapshot of what was drawn in &quot;mcDrawingBoard&quot;</span>
			bmdSnapshot.<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>mcDrawingBoard<span style="color: #000000;">&#41;</span>;
&nbsp;
			saveImage<span style="color: #000000;">&#40;</span>bmdSnapshot<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> wsMainService_InitFailed<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span>WebServiceEvent<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>
			<span style="color: #004993;">log</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Webservice failed to initialize.&quot;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> saveImage<span style="color: #000000;">&#40;</span>bmdSend<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</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>
			<span style="color: #009900;">// create a new JPEGAsyncEncoder.  80 is the JPEG quality.</span>
			<span style="color: #6699cc; font-weight: bold;">var</span> jpgEncoder<span style="color: #000000; font-weight: bold;">:</span>JPEGAsyncEncoder = <span style="color: #0033ff; font-weight: bold;">new</span> JPEGAsyncEncoder<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">80</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// encodes 400 pixels before sending out a ProgressEvent.  That means every 400 pixels the CPU has a chance to &quot;breath&quot;</span>
			<span style="color: #009900;">// and process some other code.  </span>
			jpgEncoder.PixelsPerIteration = <span style="color: #000000; font-weight:bold;">400</span>;
&nbsp;
			jpgEncoder.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>JPEGAsyncCompleteEvent.JPEGASYNC_COMPLETE, jpgEncoder_Complete<span style="color: #000000;">&#41;</span>;
			jpgEncoder.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">ProgressEvent</span>.<span style="color: #004993;">PROGRESS</span>, jpgEncoder_Progress<span style="color: #000000;">&#41;</span>;
&nbsp;
			jpgEncoder.encode<span style="color: #000000;">&#40;</span>bmdSend<span style="color: #000000;">&#41;</span>;			
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> jpgEncoder_Complete<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span>JPEGAsyncCompleteEvent<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>
			<span style="color: #6699cc; font-weight: bold;">var</span> jpgByteArray<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ByteArray</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// put the raw image data we got back from the encoder into our ByteArray</span>
			jpgByteArray = e.ImageData;
&nbsp;
			sendToServer<span style="color: #000000;">&#40;</span>jpgByteArray<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> jpgEncoder_Progress<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ProgressEvent</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>
			<span style="color: #004993;">log</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;encoding... &quot;</span> <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #004993;">Math</span>.<span style="color: #004993;">round</span><span style="color: #000000;">&#40;</span>e.<span style="color: #004993;">bytesLoaded</span> <span style="color: #000000; font-weight: bold;">/</span> e.<span style="color: #004993;">bytesTotal</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> sendToServer<span style="color: #000000;">&#40;</span>byteArray<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</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>
			<span style="color: #6699cc; font-weight: bold;">var</span> opJPEGSaver<span style="color: #000000; font-weight: bold;">:</span>Operation = <span style="color: #0033ff; font-weight: bold;">new</span> Operation<span style="color: #000000;">&#40;</span>wsMainService<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// unfortunately, I don't think the WebService class we're using has a working ProgressEvent.</span>
			<span style="color: #009900;">// if I'm wrong, please let me know!</span>
			opJPEGSaver.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>OperationEvent.<span style="color: #004993;">COMPLETE</span>, opJPEGSaver_Complete<span style="color: #000000;">&#41;</span>;
			opJPEGSaver.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>OperationEvent.FAILED, opJPEGSaver_Failed<span style="color: #000000;">&#41;</span>;	
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> strEncodedString<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #009900;">// the Base64 class is static, so we can just call it using Base64.&lt;whatever&gt;</span>
			strEncodedString = Base64.encodeByteArray<span style="color: #000000;">&#40;</span>byteArray<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// send the encoded bytes to our webservice function we called &quot;SaveJPEG&quot;.</span>
			opJPEGSaver.SaveJPEG<span style="color: #000000;">&#40;</span>strEncodedString<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> opJPEGSaver_Complete<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span>OperationEvent<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>
			<span style="color: #004993;">log</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;ByteArray successfully sent to server.&quot;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> opJPEGSaver_Failed<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span>OperationEvent<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>
			<span style="color: #004993;">log</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Error sending ByteArray to server.&quot;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">log</span><span style="color: #000000;">&#40;</span>strLog<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</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>
			<span style="color: #009900;">// my own way of tracing to the textfield txtTrace -- as you can see.</span>
			<span style="color: #009900;">// not an important part of anything going on here.</span>
			txtTrace.<span style="color: #004993;">appendText</span><span style="color: #000000;">&#40;</span>strLog <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>&quot;</span><span style="color: #000000;">&#41;</span>;
			traceScrollBar.scrollTarget = txtTrace;
			txtTrace.<span style="color: #004993;">scrollV</span> = txtTrace.<span style="color: #004993;">numLines</span>;
		<span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>




<h4>The VB.NET code:</h4>


<div class="wp_syntax"><div class="code"><pre class="vbnet"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Web</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">Services</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">Services</span>.<span style="color: #0000FF;">Protocols</span>
<span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">IO</span>
&nbsp;
<span style="color: #008080; font-style: italic;">' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.</span>
<span style="color: #008080; font-style: italic;">' &lt;System.Web.Script.Services.ScriptService()&gt; _</span>
&lt;WebService<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">Namespace</span>:<span style="color: #008000;">=</span><span style="color: #808080;">&quot;http://tempuri.org/&quot;</span><span style="color: #000000;">&#41;</span>&gt; _
&lt;WebServiceBinding<span style="color: #000000;">&#40;</span>ConformsTo:<span style="color: #008000;">=</span>WsiProfiles.<span style="color: #0000FF;">BasicProfile1_1</span><span style="color: #000000;">&#41;</span>&gt; _
&lt;Global.<span style="color: #0000FF;">Microsoft</span>.<span style="color: #0000FF;">VisualBasic</span>.<span style="color: #0000FF;">CompilerServices</span>.<span style="color: #0000FF;">DesignerGenerated</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>&gt; _
<span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Class</span> Service
     <span style="color: #0600FF;">Inherits</span> System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">Services</span>.<span style="color: #0000FF;">WebService</span>
&nbsp;
&nbsp;
    &lt;WebMethod<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>&gt; _
    <span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Function</span> SaveJPEG<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> strJPEG <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">'saves an uploaded photo and returns a unique name reference</span>
&nbsp;
        <span style="color: #0600FF;">Dim</span> BinaryContent <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Byte</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> Convert.<span style="color: #0000FF;">FromBase64String</span><span style="color: #000000;">&#40;</span>strJPEG<span style="color: #000000;">&#41;</span>
&nbsp;
        <span style="color: #0600FF;">Try</span>
            <span style="color: #008080; font-style: italic;">'generate a unique name (GUID) for the filename</span>
            <span style="color: #0600FF;">Dim</span> strFileName <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> System.<span style="color: #0000FF;">Guid</span>.<span style="color: #0000FF;">NewGuid</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;n&quot;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #008080; font-style: italic;">'MAKE SURE to change the save path!</span>
            <span style="color: #0600FF;">Dim</span> fStream <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> FileStream<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;C:\&quot;</span> <span style="color: #008000;">+</span> strFileName <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;.jpg&quot;</span>, FileMode.<span style="color: #0000FF;">CreateNew</span><span style="color: #000000;">&#41;</span>
            <span style="color: #0600FF;">Dim</span> bw <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">New</span> BinaryWriter<span style="color: #000000;">&#40;</span>fStream<span style="color: #000000;">&#41;</span>
&nbsp;
            bw.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span>BinaryContent<span style="color: #000000;">&#41;</span>
            bw.<span style="color: #0600FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
            fStream.<span style="color: #0600FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">'return the filename for use in Flash</span>
            <span style="color: #FF8000;">Return</span> strFileName
&nbsp;
        <span style="color: #0600FF;">Catch</span> ex <span style="color: #FF8000;">As</span> Exception
&nbsp;
            <span style="color: #FF8000;">Return</span> ex.<span style="color: #0000FF;">Message</span>
&nbsp;
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Try</span>
&nbsp;
    <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></pre></div></div>


]]></content:encoded>
			<wfw:commentRss>http://ryanbosinger.com/blog/2008/saving-images-with-net/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Joke: What would it be like to have thirty dogs?</title>
		<link>http://ryanbosinger.com/blog/2008/joke-what-would-it-be-like-to-have-thirty-dogs/</link>
		<comments>http://ryanbosinger.com/blog/2008/joke-what-would-it-be-like-to-have-thirty-dogs/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 20:53:06 +0000</pubDate>
		<dc:creator>rbosinger</dc:creator>
		
		<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://ryanbosinger.com/blog/?p=36</guid>
		<description><![CDATA[


Question:  What do you think it would be like to have thirty dogs?



Answer:  Ruff!



Only you would bark that answer at the person before they really had any time to think about it.


I made that up a couple weeks ago, I thought it was pretty funny.  Tell everybody.
]]></description>
			<content:encoded><![CDATA[<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/08/dogs.jpg'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/08/dogs.jpg" alt="" title="Dog Walker" class="aligncenter wp-image-37" /></a>

<p>
<strong>Question: </strong> What do you think it would be like to have thirty dogs?
</p>

<p>
<strong>Answer: </strong> Ruff!
</p>

<p>
Only you would <em>bark</em> that answer at the person before they really had any time to think about it.
</p>
<p>
I made that up a couple weeks ago, I thought it was pretty funny.  Tell everybody.
</p>]]></content:encoded>
			<wfw:commentRss>http://ryanbosinger.com/blog/2008/joke-what-would-it-be-like-to-have-thirty-dogs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Actionscript 3.0:  Scale Object from Center Point</title>
		<link>http://ryanbosinger.com/blog/2008/actionscript-30-scale-object-from-center-point/</link>
		<comments>http://ryanbosinger.com/blog/2008/actionscript-30-scale-object-from-center-point/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 19:52:29 +0000</pubDate>
		<dc:creator>rbosinger</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

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

		<guid isPermaLink="false">http://ryanbosinger.com/blog/?p=35</guid>
		<description><![CDATA[
Note: This is almost exactly the same solution I posted earlier for rotating an object around its center point (Actionscript 3.0: Rotate Around Center Point).  I thought I&#8217;d post this slightly altered solution for people who need it.


    
        
     [...]]]></description>
			<content:encoded><![CDATA[<p>
<em>Note: This is almost exactly the same solution I posted earlier for rotating an object around its center point (<a href="/blog/2008/actionscript-30-rotate-around-center-point/">Actionscript 3.0: Rotate Around Center Point</a>).  I thought I&#8217;d post this slightly altered solution for people who need it.</em>
</p>

    <div class="problem-solution">
        <p class="problem">
            <strong>
                Problem:
            </strong>
        </p> 
        <blockquote>
You need to scale a movieclip/sprite from its center point, but its registration point is at (0,0) and you can&#8217;t and/or don&#8217;t feel like putting this object in the center of a container movieclip and rotating that
        </blockquote> 
        
        <p class="solution">
            <strong>
                Solution:
            </strong>
        </p>
        <blockquote>
            TCBWMO (Take care of business with the matrix object).
        </blockquote>
    </div>

<span id="more-35"></span>
<p>
Here&#8217;s the function:
</p>


<div class="wp_syntax"><div class="code"><pre class="actionscript3"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> scaleFromCenter<span style="color: #000000;">&#40;</span>ob<span style="color: #000000; font-weight: bold;">:*</span>, sx<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>, sy<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>, ptScalePoint<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Point</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> 
	<span style="color: #6699cc; font-weight: bold;">var</span> m<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Matrix</span>=ob.<span style="color: #004993;">transform</span>.<span style="color: #004993;">matrix</span>;
	m.<span style="color: #004993;">tx</span> <span style="color: #000000; font-weight: bold;">-</span>= ptScalePoint.<span style="color: #004993;">x</span>;
	m.<span style="color: #004993;">ty</span> <span style="color: #000000; font-weight: bold;">-</span>= ptScalePoint.<span style="color: #004993;">y</span>;
	m.<span style="color: #004993;">scale</span><span style="color: #000000;">&#40;</span>sx, sy<span style="color: #000000;">&#41;</span>;
	m.<span style="color: #004993;">tx</span> <span style="color: #000000; font-weight: bold;">+</span>= ptScalePoint.<span style="color: #004993;">x</span>;
	m.<span style="color: #004993;">ty</span> <span style="color: #000000; font-weight: bold;">+</span>= ptScalePoint.<span style="color: #004993;">y</span>;
	ob.<span style="color: #004993;">transform</span>.<span style="color: #004993;">matrix</span> = m;
<span style="color: #000000;">&#125;</span></pre></div></div>




<div class="google_ads_01">
<script type="text/javascript"><!--
google_ad_client = "pub-1962502741893893";
/* 468x60, created 5/27/08 */
google_ad_slot = "8820555819";
google_ad_width = 468;
google_ad_height = 60;
//-->
// &#8211;&gt;</script>
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
</div>

<p>
Now to make this work, you could call it like this:
</p>


<div class="wp_syntax"><div class="code"><pre class="actionscript3"><span style="color: #009900;">//this will create a point object at the center of the display object</span>
ptRotationPoint = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span>mcPhoto.<span style="color: #004993;">x</span> <span style="color: #000000; font-weight: bold;">+</span> mcPhoto.<span style="color: #004993;">width</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span>, mcPhoto.<span style="color: #004993;">y</span> <span style="color: #000000; font-weight: bold;">+</span> mcPhoto.<span style="color: #004993;">height</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">//call the function and pass in the object to be rotated, the amount to scale X and Y (sx, sy), and the point object we created</span>
scaleFromCenter<span style="color: #000000;">&#40;</span>mcPhoto, <span style="color: #000000; font-weight:bold;">2</span>, <span style="color: #000000; font-weight:bold;">2</span>, ptScalePoint<span style="color: #000000;">&#41;</span>;</pre></div></div>




<p>
In this example we&#8217;re subbing in &#8220;2&#8243; for both the <em>sx</em> and <em>sy</em> values.  This will scale our image to twice its size.  If you want to scale down, use numbers lower than 1.
</p>]]></content:encoded>
			<wfw:commentRss>http://ryanbosinger.com/blog/2008/actionscript-30-scale-object-from-center-point/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flash/Actionscript: Innaccurate math results</title>
		<link>http://ryanbosinger.com/blog/2008/flashactionscript-innaccurate-math-results/</link>
		<comments>http://ryanbosinger.com/blog/2008/flashactionscript-innaccurate-math-results/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 18:10:45 +0000</pubDate>
		<dc:creator>rbosinger</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

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

		<guid isPermaLink="false">http://ryanbosinger.com/blog/?p=34</guid>
		<description><![CDATA[
    
        
            Problem:
        
     
    
You&#8217;re working some math equations with Actionscript and tracing the results when you notice [...]]]></description>
			<content:encoded><![CDATA[<div class="problem-solution">
    <p class="problem">
        <strong>
            Problem:
        </strong>
    </p> 
    <blockquote>
You&#8217;re working some math equations with Actionscript and tracing the results when you notice some results are off by a very small value.
<br />
<em><strong>output:</strong></em>
<pre>
2
2.1
2.2
2.3
2.4
2.5000000001
2.6
2.7000000001
2.8
2.9
3
</pre>
    </blockquote> 
    
    <p class="solution">
        <strong>
            Solution:
        </strong>
    </p>
    <blockquote>
This is called a <em>floating point error</em> and is apparently a normal computing error that affects all aspects of computing, not just flash.   You can fix this by running the values through the <em>correctFloatingPointError</em> function I&#8217;ve posted below.
    </blockquote>
</div>

<span id="more-34"></span>
<p>
I originally found this information/code on a post called <a href="http://www.zeuslabs.us/2007/01/30/flash-floating-point-number-errors/">Floating-point errors got you down?</a>
</p>

<div class="google_ads_01">
<script type="text/javascript"><!--
google_ad_client = "pub-1962502741893893";
/* 468x60, created 5/27/08 */
google_ad_slot = "8820555819";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

<p>
I won&#8217;t repeat everything I read there, you can check that out yourself.  However, I thought I would re-post this information with the heading &#8220;Innaccurate math results&#8221; because that&#8217;s what I had been searching for before I realized I was experiencing a floating point error.  Anyway, here&#8217;s the code:
</p>


<div class="wp_syntax"><div class="code"><pre class="actionscript3"><span style="color: #3f5fbf;">/**
 * Corrects errors caused by floating point math.
 */</span>
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> correctFloatingPointError<span style="color: #000000;">&#40;</span>number<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>, precision<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #009900;">//default returns (10000 * number) / 10000</span>
	<span style="color: #009900;">//should correct very small floating point errors</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> correction<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span>, precision<span style="color: #000000;">&#41;</span>;
	<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">Math</span>.<span style="color: #004993;">round</span><span style="color: #000000;">&#40;</span>correction <span style="color: #000000; font-weight: bold;">*</span> number<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">/</span> correction;
<span style="color: #000000;">&#125;</span>
<span style="color: #3f5fbf;">/**
 * Tests if two numbers are &lt;em&gt;almost&lt;/em&gt; equal.
 */</span>
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> fuzzyEquals<span style="color: #000000;">&#40;</span>number1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>, number2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span>, precision<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> difference<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = number1 <span style="color: #000000; font-weight: bold;">-</span> number2;
	<span style="color: #6699cc; font-weight: bold;">var</span> range<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Math</span>.<span style="color: #004993;">pow</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">10</span>, <span style="color: #000000; font-weight: bold;">-</span>precision<span style="color: #000000;">&#41;</span>;
	<span style="color: #009900;">//default check:</span>
	<span style="color: #009900;">//0.00001 &lt;difference&gt; -0.00001</span>
	<span style="color: #0033ff; font-weight: bold;">return</span> difference <span style="color: #000000; font-weight: bold;">&lt;</span>range <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> difference<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">-</span>range;
<span style="color: #000000;">&#125;</span>
<span style="color: #3f5fbf;">/*
Copyright (c) 2007 Josh Tynjala
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the &quot;Software&quot;), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/</span></pre></div></div>




]]></content:encoded>
			<wfw:commentRss>http://ryanbosinger.com/blog/2008/flashactionscript-innaccurate-math-results/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using the free Flex 3 SDK with Flash Develop</title>
		<link>http://ryanbosinger.com/blog/2008/using-the-free-flex-3-sdk-with-flash-develop/</link>
		<comments>http://ryanbosinger.com/blog/2008/using-the-free-flex-3-sdk-with-flash-develop/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 17:40:50 +0000</pubDate>
		<dc:creator>rbosinger</dc:creator>
		
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://ryanbosinger.com/blog/?p=26</guid>
		<description><![CDATA[
Recently I got back into Flash and began to learn Actionscript 3.0.  Things have definitely come a long way in the last few years, and I&#8217;ve become interested in Adobe&#8217;s quest to turn the Flash format into a full fledged rich internet application framework of sorts.  I&#8217;m surprised, and personally impressed on how [...]]]></description>
			<content:encoded><![CDATA[<p>
Recently I got back into Flash and began to learn Actionscript 3.0.  Things have definitely come a long way in the last few years, and I&#8217;ve become interested in Adobe&#8217;s quest to turn the Flash format into a full fledged rich internet application framework of sorts.  I&#8217;m surprised, and personally impressed on how far all this has come.  Here&#8217;s a couple things I&#8217;ve come to realize (or knew about, but never dived into) in the last year or so:
</p>
<span id="more-26"></span>
<ul>
	<li><strong>You don&#8217;t actually need Flash/Flex Builder to make Flash anymore</strong>
There&#8217;s plenty of free, open-source ways to compile Actionscript and MXML and end up with SWF file.</li>
	<li> <strong>Flex is actually pretty cool</strong>
I think I was one of many that had mis-perceptions about Flex.  All it really is, is a way to use the Flash format to create data rich internet applications.  You still end up with a SWF file and you don&#8217;t necessarily need any special server software.</li>
</ul>
<p>
I don&#8217;t know much about Flex yet, except that it reminds me a lot of ASP.NET in the sense that it has a lot of similar data controls and similar terms.  Flex, however, is only for the front-end interface and you will still need a server side solution such as PHP or ASP.NET to actually handle the data.  What&#8217;s cool is that Flex has style and because the end result runs in the Flash player it should be a consistent experience across all browsers.  You also have the freedom to do any type of animation and effects you can do with Flash/Actionscript with the full confidence it will work as planned.
</p>

<div class="google_ads_01">
<script type="text/javascript"><!--
google_ad_client = "pub-1962502741893893";
/* 468x60, created 5/27/08 */
google_ad_slot = "8820555819";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

<ul>
	<li><strong><a href="http://opensource.adobe.com/wiki/display/flexsdk/Downloads">Download the &#8220;Free Adobe Flex SDK&#8221;</a></strong>
You may notice there is also an open-source version.  I wouldn&#8217;t recommend this for starting.  Because the entire Flex SDK isn&#8217;t open-source, the open-source version lacks anything that <em>isn&#8217;t</em> open-source.  This could mean that while learning you may try something that doesn&#8217;t work and become confused as to why.</li>
	<li> <strong><a href="http://osflash.org/flashdevelop">Download &#8220;Flash Develop&#8221;</a></strong>
At the time of this post, Flash Develop 3.0 is in its Beta 7.  Download this or a later version if available.
<em>Note:</em> An up to date Java runtime and .NET framework are required to run this software.  This information is available at the link I provided.</li>
        <li>Unzip the contents of flex_3_sdk.zip directly into a folder called &#8220;flex3sdk&#8221;.  I put mine directly on the root of my C drive (C:\flex3sdk)</li>
        <li>Install and run FlashDevelop</li>
        <li>From the menu choose <em>Project > New Project</em></li>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/07/screenhunter_01-jul-07-2224.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/07/screenhunter_01-jul-07-2224.gif" alt="FlashDevelop screenshot" title="flashdevelop_01-jul-07-2224" width="369" height="268" class="aligncenter size-full wp-image-27" /></a>
        <li>Select <em>Actionscript 3.0 > Default Project</em>.  Give it a name or whatever.</li>
<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/07/screenhunter_02-jul-07-2228.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/07/screenhunter_02-jul-07-2228.gif" alt="FlashDevelop screenshot" title="flashdevelop_02-jul-07-2228" width="415" height="334" class="aligncenter size-full wp-image-28" /></a>

       <li><strong>The important part:</strong> Go to <em>Tools > Program Settings&#8230; </em>(F10) and select <em>AS3 Context</em>.  This is how we point FlashDevelop to the Flex 3 SDK which we will use to compile our SWF.   FlashDevelop cannot do this on it&#8217;s own although it can use the Flash IDE compiler if you own Flash. </li>

<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/07/screenhunter_08-jul-07-2235.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/07/screenhunter_08-jul-07-2235.gif" alt="FlashDevelop program settings (set compiler)" title="flashdevelop_08-jul-07-2235" width="537" height="380" class="aligncenter size-full wp-image-29" /></a>

<li>Next, let&#8217;s open up our main document class.  FlashDevelop has already made one for us.  Open the &#8220;src&#8221; folder in the Project window on the right hand side.  Open &#8220;main.as&#8221;.</li>

<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/07/screenhunter_07-jul-07-2234.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/07/screenhunter_07-jul-07-2234.gif" alt="" title="flashdevelop_07-jul-07-2234" width="370" height="240" class="aligncenter size-full wp-image-30" /></a>

<li>Take it for a test drive by pasting in the code below and selecting <em>Project > Test Movie</em> or F5.</li>

</ul>

<div class="google_ads_01">
<script type="text/javascript"><!--
google_ad_client = "pub-1962502741893893";
/* 468x60, created 5/27/08 */
google_ad_slot = "8820555819";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


<div class="wp_syntax"><div class="code"><pre class="actionscript3"><span style="color: #9900cc; font-weight: bold;">package</span> 
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">MovieClip</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Sprite</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">StageScaleMode</span>;
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span> = <span style="color: #990000;">&quot;350&quot;</span>, <span style="color: #004993;">height</span> = <span style="color: #990000;">&quot;200&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main extends <span style="color: #004993;">Sprite</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> myMovieClip<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MovieClip</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">MovieClip</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</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>
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">scaleMode</span> = <span style="color: #004993;">StageScaleMode</span>.<span style="color: #004993;">NO_SCALE</span>;
			myMovieClip.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0x000000<span style="color: #000000;">&#41;</span>;
			myMovieClip.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span>, <span style="color: #000000; font-weight:bold;">50</span>, <span style="color: #000000; font-weight:bold;">150</span>, <span style="color: #000000; font-weight:bold;">75</span><span style="color: #000000;">&#41;</span>;
			myMovieClip.<span style="color: #004993;">graphics</span>.<span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>myMovieClip<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>




<p>&#8230; and here we go, a nice little black rectangle.  Totally worth it.</p>

<a href='http://ryanbosinger.com/blog/wp-content/uploads/2008/07/screenhunter_09-jul-07-2252.gif'><img src="http://ryanbosinger.com/blog/wp-content/uploads/2008/07/screenhunter_09-jul-07-2252.gif" alt="Flash screenshot example" title="flashexample-jul-07-2252" width="363" height="261" class="aligncenter size-full wp-image-31" /></a>]]></content:encoded>
			<wfw:commentRss>http://ryanbosinger.com/blog/2008/using-the-free-flex-3-sdk-with-flash-develop/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
