<?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>YTechie.com &#187; actionscript</title>
	<atom:link href="http://www.ytechie.com/category/actionscript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ytechie.com</link>
	<description>Productive software development using ASP.NET, C#, Adobe Flex, and other technologies and tools.</description>
	<lastBuildDate>Fri, 06 Nov 2009 21:16:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Take a screenshot in Flex and send it to ASP.NET</title>
		<link>http://www.ytechie.com/2008/04/take-a-screenshot-in-flex-and-send-it-to-aspnet.html</link>
		<comments>http://www.ytechie.com/2008/04/take-a-screenshot-in-flex-and-send-it-to-aspnet.html#comments</comments>
		<pubDate>Tue, 22 Apr 2008 17:52:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://207.36.235.13/2008/04/take-a-screenshot-in-flex-and-send-it-to-aspnet.html</guid>
		<description><![CDATA[In Adobe Flex 3, you can get a bitmap image of any control by using this code (you&#8217;ll need to import &#34;mx.graphics.ImageSnapshot&#34;):
var snapshot:ImageSnapshot =  ImageSnapshot.captureImage(backgroundCanvas);
By default, it uses PNG encoding.
If you want to then send this image to the server, use this code:
var req:URLRequest = new URLRequest();
req.method = URLRequestMethod.POST;
req.data = snapshot.data;
req.contentType=&#34;application/octet-stream&#34;;
req.url = &#34;snapshotuploadhandler.aspx&#34;;
var loader:URLLoader [...]]]></description>
			<content:encoded><![CDATA[<p>In Adobe Flex 3, you can get a bitmap image of any control by using this code (you&#8217;ll need to import &quot;mx.graphics.ImageSnapshot&quot;):</p>
<pre class="javascript" name="code">var snapshot:ImageSnapshot =  ImageSnapshot.captureImage(backgroundCanvas);</pre>
<p>By default, it uses PNG encoding.</p>
<p>If you want to then send this image to the server, use this code:</p>
<pre class="javascript" name="code">var req:URLRequest = new URLRequest();
req.method = URLRequestMethod.POST;
req.data = snapshot.data;
req.contentType=&quot;application/octet-stream&quot;;
req.url = &quot;snapshotuploadhandler.aspx&quot;;
var loader:URLLoader = new URLLoader;
loader.load(req);</pre>
<p>Reading the uploaded file is easy using ASP.NET:</p>
<pre class="c-sharp" name="code">private byte[] readPostedFile()
{
   if (Request.ContentLength &gt; 0)
   {
       byte[] buffer = new byte[Request.ContentLength];
       using (BinaryReader br = new BinaryReader(Request.InputStream))
           br.Read(buffer, 0, buffer.Length);
       return buffer;
   }
   else
   {
       return null;
   }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ytechie.com/2008/04/take-a-screenshot-in-flex-and-send-it-to-aspnet.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Uninitialized variables in Adobe Flex &quot;for&quot; loops</title>
		<link>http://www.ytechie.com/2008/03/uninitialized-variables-in-adobe-flex-for-loops.html</link>
		<comments>http://www.ytechie.com/2008/03/uninitialized-variables-in-adobe-flex-for-loops.html#comments</comments>
		<pubDate>Mon, 31 Mar 2008 21:10:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://207.36.235.13/2008/03/uninitialized-variables-in-adobe-flex-for-loops.html</guid>
		<description><![CDATA[for(var j:int; j &#60; editAreas.length; j++)
    trace(&#34;doing something&#34;);
What&#8217;s wrong with this ActionScript code? This was a block of code that I fixed while tracking down a nasty bug. c# would have never let me do this.

Basically, the &#34;j&#34; variable starts out at 0 in the method. That&#8217;s fine, because it&#8217;s what I [...]]]></description>
			<content:encoded><![CDATA[<pre class="javascript" name="code">for(var j:int; j &lt; editAreas.length; j++)
    trace(&quot;doing something&quot;);</pre>
<p>What&#8217;s wrong with this ActionScript code? This was a block of code that I fixed while tracking down a nasty bug. c# would have never let me do this.</p>
<p><img height="110" alt="image" src="/post-images/2008/03/no-bugs.png" width="110" border="0" /></p>
<p>Basically, the &quot;j&quot; variable starts out at 0 in the method. That&#8217;s fine, because it&#8217;s what I would normally expect. The problem is that I have it declared inside another loop, so this loop initializer is run multiple times. The second time around, &quot;j&quot; maintains it&#8217;s value. It could start at 5 next time. The loop still partially works, if the length of the arrays get longer each time. It&#8217;s a bit odd that the &quot;j&quot; variable is never created more than once. I&#8217;m guessing it&#8217;s a compiler optimization.</p>
<p>This loop was used in a drawing routine for images. If you had an image in the first drawing area, the first image in the consecutive drawing areas would never be drawn.</p>
<p>It should be obvious, but please don&#8217;t forget to initialize your &quot;for&quot; loop variables.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ytechie.com/2008/03/uninitialized-variables-in-adobe-flex-for-loops.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
