<?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>zedia flash blog &#187; as3corelib</title>
	<atom:link href="http://www.zedia.net/tag/as3corelib/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zedia.net</link>
	<description>Flash, ActionScript, SEO and everything in between</description>
	<lastBuildDate>Thu, 02 Feb 2012 17:58:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Sending byteArray (image) and variables to server-side script as POST data in AS3</title>
		<link>http://www.zedia.net/2010/sending-bytearray-image-and-variables-to-server-side-script-as-post-data-in-as3/</link>
		<comments>http://www.zedia.net/2010/sending-bytearray-image-and-variables-to-server-side-script-as-post-data-in-as3/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 17:07:49 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[2007]]></category>
		<category><![CDATA[as3corelib]]></category>
		<category><![CDATA[ByteArray]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[Jonathan Marston]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[server-side]]></category>
		<category><![CDATA[UploadPostHelper]]></category>

		<guid isPermaLink="false">http://www.zedia.net/?p=687</guid>
		<description><![CDATA[A couple things here, I first talked about how to send an image and variables to the server (at the same time) on this post, but it felt a bit weird, the file had no name to retrieve it and the variables were sent as GET. Now while working a with a new colleague, he showed [...]]]></description>
			<content:encoded><![CDATA[<p>A couple things here, I first talked about how to send an image and variables to the server (at the same time) <a title="Sending byteArray and variables to server-side script at the same time" href="http://www.zedia.net/2008/sending-bytearray-and-variables-to-server-side-script-at-the-same-time/" target="_blank">on this post</a>, but it felt a bit weird, the file had no name to retrieve it and the variables were sent as GET. Now while working a with a new colleague, he showed me this code that for him was nothing but for me was amazing. It is a little library called UploadPostHelper made by <a title="Jonathan Marston" href="http://marstonstudio.com/" target="_blank">Jonathan Marston</a> back in 2007 (2007! why didn&#8217;t someone talk to me about this library before!!!).</p>
<p>Anyway here is a little code snippet showing how to use it:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> jpegEncoder:JPGEncoder = <span style="color: #000000; font-weight: bold;">new</span> JPGEncoder<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">85</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//using the JPGEncoder from as3corelib</span>
<span style="color: #000000; font-weight: bold;">var</span> jpegBytes:ByteArray = jpegEncoder.<span style="color: #006600;">encode</span><span style="color: #66cc66;">&#40;</span>myPicture.<span style="color: #006600;">bitmapData</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//encoding a Bitmap into a ByteArray</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> urlRequest : URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
urlRequest.<span style="color: #0066CC;">url</span> = <span style="color: #ff0000;">&quot;THE URL OF YOUR SERVER SIDE SCRIPT&quot;</span>;
urlRequest.<span style="color: #0066CC;">contentType</span> = <span style="color: #ff0000;">'multipart/form-data; boundary='</span> + UploadPostHelper.<span style="color: #006600;">getBoundary</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
urlRequest.<span style="color: #006600;">method</span> = URLRequestMethod.<span style="color: #006600;">POST</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">//now create an object with the variables you want to send as POST</span>
<span style="color: #000000; font-weight: bold;">var</span> postVariables:<span style="color: #0066CC;">Object</span> = <span style="color: #66cc66;">&#123;</span>variable1Name:variable1Data, variable21Name:variable2Data, variable3Name:variable3Data<span style="color: #66cc66;">&#125;</span>
urlRequest.<span style="color: #0066CC;">data</span> = UploadPostHelper.<span style="color: #006600;">getPostData</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'image.jpg'</span>, jpegBytes,<span style="color: #ff0000;">&quot;filedata&quot;</span>, postVariables<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//here is where the magic happens, filedata will be the name to retrieve the file</span>
urlRequest.<span style="color: #006600;">requestHeaders</span>.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> URLRequestHeader<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'Cache-Control'</span>, <span style="color: #ff0000;">'no-cache'</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">//from here it is just a normal URLLoader</span>
_pictureUploader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
_pictureUploader.<span style="color: #006600;">dataFormat</span> = URLLoaderDataFormat.<span style="color: #006600;">BINARY</span>;
_pictureUploader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">COMPLETE</span>, _onUploadComplete, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>;
_pictureUploader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span> urlRequest <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>How easy and beautiful is that?</p>
<p>So can get the code for the UploadPostHelper at the bottom of <a title="UploadPostHelper" href="http://marstonstudio.com/2007/10/19/how-to-take-a-snapshot-of-a-flash-movie-and-automatically-upload-the-jpg-to-a-server-in-three-easy-steps/" target="_blank">this post</a> or I have made a zip file with the <a title="UploadPostHelper" href="http://www.zedia.net/files/UploadPostHelper.zip" target="_blank">.as file here</a>.</p>
<p>Dude, 2007!</p>
 <p><a href="http://www.zedia.net/?flattrss_redirect&amp;id=687&amp;md5=40613c83d6397a471535f247ebaaa1aa" title="Flattr" target="_blank"><img src="http://www.zedia.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2010/sending-bytearray-image-and-variables-to-server-side-script-as-post-data-in-as3/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Prepare to Roar</title>
		<link>http://www.zedia.net/2009/prepare-to-roar/</link>
		<comments>http://www.zedia.net/2009/prepare-to-roar/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 19:50:47 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[Twist Image]]></category>
		<category><![CDATA[Alcon]]></category>
		<category><![CDATA[as3corelib]]></category>
		<category><![CDATA[facebook api]]></category>
		<category><![CDATA[Google Analytics for Flash]]></category>
		<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[Roar 4 Milk]]></category>
		<category><![CDATA[TweenLite]]></category>

		<guid isPermaLink="false">http://www.zedia.net/?p=470</guid>
		<description><![CDATA[If you have been wondering why I haven&#8217;t been writting a lot this summer, well it&#8217;s been mostly because of this project. I learned a great deal on Papervision3D, using the webcam, on playing with bitmaps and on Facebook connect (even if I wasn&#8217;t the one doing that part) while building this project. So here [...]]]></description>
			<content:encoded><![CDATA[<p>If you have been wondering why I haven&#8217;t been writting a lot this summer, well it&#8217;s been mostly because of this project. I learned a great deal on Papervision3D, using the webcam, on playing with bitmaps and on Facebook connect (even if I wasn&#8217;t the one doing that part) while building this project. So here you go, create some roars:</p>
<p><a title="Roar 4 Milk" href="http://www.roar4milk.ca" target="_blank">http://www.roar4milk.ca</a></p>
<p>The goal of the campaign was to get teens involved with milk and to build on some ad spots that performed very well on MTV. So what you are doing with this application is recreating the ads but adding yourself at the end instead of the cow. Now I knowthat the site is a bit (to say the least) CPU intensive (3D tends to do this), but believe me it was worse than this before and I wish I would have had a bit more time to perfect this site.</p>
<p>The technical cool part is that you can use your picture, be it by uploading it or using your webcam, and using the derivate bitmap I will composite it with the cow skin and apply that to the loaded Collada model. That was kind of the premise of this site and we built around it with a vintage design. I hope you like it.</p>
<p>Here is a short list of librairies we used: as3corelib, TweenLite, Alcon, facebook api, google analytics for flash and Papervision3D.</p>
<p>Another cool feature is that you can embed your roar on your blog like this:</p>
<p><script type="text/javascript" src="http://www.roar4milk.ca/embedJS.php?roarId=8f14e7c8e2786f83abd7ca5b379006c3"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2009/prepare-to-roar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to connect to Google Analytics Data API in AIR</title>
		<link>http://www.zedia.net/2009/how-to-connect-to-google-analytics-data-api-in-air/</link>
		<comments>http://www.zedia.net/2009/how-to-connect-to-google-analytics-data-api-in-air/#comments</comments>
		<pubDate>Fri, 22 May 2009 03:37:38 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[as3corelib]]></category>
		<category><![CDATA[as3crypto]]></category>
		<category><![CDATA[as3httpclientlib]]></category>
		<category><![CDATA[GData]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Google Analytics Data Api]]></category>

		<guid isPermaLink="false">http://www.zedia.net/?p=415</guid>
		<description><![CDATA[I had a bit of trouble doing just this a while ago, ended up trying many different ways and finally a reader of this blog, Nakamachi, gave me the solution. Because I think many of you are trying to connect to Google Analytics Data API ( or any Google APIs for that matters) I will [...]]]></description>
			<content:encoded><![CDATA[<p>I had a bit of trouble doing <a title="Connecting to Google Analytics Data Api using AS3; my failures" href="http://www.zedia.net/2009/connecting-to-google-analytics-data-api-using-as3-my-failures/" target="_self">just this a while ago</a>, ended up trying many different ways and finally a reader of this blog, <span class="info">Nakamachi, gave me the solution. Because I think many of you are trying to connect to Google Analytics Data API ( or any Google APIs for that matters) I will give you here my solution. My solution only works in AIR; I don&#8217;t know why, but as soon as I put it on the web, it stops working. I have found a solution for that problem too but I will keep it for another post.</span><br />
Here is how you can connect to GData:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> org.<span style="color: #006600;">httpclient</span>.<span style="color: #006600;">HttpClient</span>;
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">adobe</span>.<span style="color: #006600;">net</span>.<span style="color: #006600;">URI</span>;
<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">httpclient</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">HttpResponseEvent</span>;
<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">httpclient</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">HttpRequestEvent</span>;
<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">httpclient</span>.<span style="color: #006600;">HttpRequest</span>;
<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">httpclient</span>.<span style="color: #006600;">http</span>.<span style="color: #0066CC;">Get</span>;
<span style="color: #0066CC;">import</span> org.<span style="color: #006600;">httpclient</span>.<span style="color: #006600;">events</span>.<span style="color: #006600;">HttpDataEvent</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> _firstBuffer:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
<span style="color: #000000; font-weight: bold;">var</span> _secondBuffer:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">//this first connection will get the authorization token by sending the user name and password for Google Analytics</span>
<span style="color: #000000; font-weight: bold;">function</span> submitForm<span style="color: #66cc66;">&#40;</span>email:<span style="color: #0066CC;">String</span>, <span style="color: #0066CC;">password</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> client:HttpClient = <span style="color: #000000; font-weight: bold;">new</span> HttpClient<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">var</span> uri:URI = <span style="color: #000000; font-weight: bold;">new</span> URI<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;https://www.google.com/accounts/ClientLogin&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">var</span> variables:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">name</span>:<span style="color: #ff0000;">&quot;accountType&quot;</span>, value:<span style="color: #ff0000;">&quot;GOOGLE&quot;</span><span style="color: #66cc66;">&#125;</span>, <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">name</span>:<span style="color: #ff0000;">&quot;Email&quot;</span>, value: email<span style="color: #66cc66;">&#125;</span>, <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">name</span>:<span style="color: #ff0000;">&quot;Passwd&quot;</span>, value: <span style="color: #0066CC;">password</span><span style="color: #66cc66;">&#125;</span>, <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">name</span>:<span style="color: #ff0000;">&quot;service&quot;</span>, value: <span style="color: #ff0000;">&quot;analytics&quot;</span><span style="color: #66cc66;">&#125;</span>, <span style="color: #66cc66;">&#123;</span><span style="color: #0066CC;">name</span>:<span style="color: #ff0000;">&quot;source&quot;</span>, value: <span style="color: #ff0000;">&quot;your-application-identifier&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#93;</span>;
  client.<span style="color: #006600;">listener</span>.<span style="color: #0066CC;">onData</span> = _onFirstData;
  client.<span style="color: #006600;">listener</span>.<span style="color: #006600;">onComplete</span> = _onLoaderComplete;
  client.<span style="color: #006600;">postFormData</span><span style="color: #66cc66;">&#40;</span>uri, variables<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> _onFirstData<span style="color: #66cc66;">&#40;</span>event:HttpDataEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  _firstBuffer += event.<span style="color: #006600;">readUTFBytes</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">//this second connection will request information to GData</span>
<span style="color: #808080; font-style: italic;">//in this case account info for Google Analytics by</span>
<span style="color: #808080; font-style: italic;">//putting the auth token in the header of the request</span>
<span style="color: #000000; font-weight: bold;">function</span> _onLoaderComplete<span style="color: #66cc66;">&#40;</span>event:HttpResponseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> tempArray:<span style="color: #0066CC;">Array</span> = _firstBuffer.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Auth=&quot;</span><span style="color: #66cc66;">&#41;</span>;
 <span style="color: #000000; font-weight: bold;">var</span>  _authToken:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>tempArray<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
  <span style="color: #000000; font-weight: bold;">var</span> client:HttpClient = <span style="color: #000000; font-weight: bold;">new</span> HttpClient<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">var</span> uri:URI = <span style="color: #000000; font-weight: bold;">new</span> URI<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;https://www.google.com/analytics/feeds/accounts/default&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #000000; font-weight: bold;">var</span> request:HttpRequest = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Get</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  request.<span style="color: #006600;">addHeader</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Authorization&quot;</span>, <span style="color: #ff0000;">&quot;GoogleLogin auth=&quot;</span> + _authToken<span style="color: #66cc66;">&#41;</span>;
&nbsp;
  client.<span style="color: #006600;">listener</span>.<span style="color: #0066CC;">onData</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>event:HttpDataEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
    _secondBuffer += event.<span style="color: #006600;">readUTFBytes</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
  client.<span style="color: #006600;">listener</span>.<span style="color: #006600;">onComplete</span> = _onSecondLoaderComplete;
  client.<span style="color: #006600;">request</span><span style="color: #66cc66;">&#40;</span>uri, request<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> _onSecondLoaderComplete<span style="color: #66cc66;">&#40;</span>event:HttpResponseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">trace</span> <span style="color: #66cc66;">&#40;</span>_secondBuffer<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>As you can see in order to circumvent the Authorization header restriction I am using the <a title="as3httpclientlib" href="http://code.google.com/p/as3httpclientlib/">as3httpclientlib</a> library which requires the <a title="as3corelib" href="http://code.google.com/p/as3corelib/" target="_blank">as3corelib</a> and <a title="as3crypto" href="http://code.google.com/p/as3crypto/" target="_blank">as3crypto</a> libraries to compile. Using the same principle you should be able to connect to Google APIs from your AIR application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2009/how-to-connect-to-google-analytics-data-api-in-air/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>as3Crypto and php, what a fun ride!</title>
		<link>http://www.zedia.net/2009/as3crypto-and-php-what-a-fun-ride/</link>
		<comments>http://www.zedia.net/2009/as3crypto-and-php-what-a-fun-ride/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 03:08:33 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Advanced Encryption Standard]]></category>
		<category><![CDATA[AES]]></category>
		<category><![CDATA[as3corelib]]></category>
		<category><![CDATA[as3crypto]]></category>
		<category><![CDATA[cryptography]]></category>
		<category><![CDATA[decrypt]]></category>
		<category><![CDATA[encrypt]]></category>
		<category><![CDATA[mcrypt]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.zedia.net/?p=393</guid>
		<description><![CDATA[Actually not so fun, but I did manage (I should say we because I wasn&#8217;t alone in this). Cryptography is not my thing, eh, not everything can be your thing so I accept it. There is just too much to learn: hash functions, public keys, symmetric ciphers, etc. Want we wanted to do was to [...]]]></description>
			<content:encoded><![CDATA[<p>Actually not so fun, but I did manage (I should say we because I wasn&#8217;t alone in this). Cryptography is not my thing, eh, not everything can be your thing so I accept it. There is just too much to learn: hash functions, public keys, symmetric ciphers, etc. Want we wanted to do was to encrypt data on the As3 side and decrypt it on the php side. I was aware that there was some cryptographic algorythms in the <a title="As3CoreLib" href="http://code.google.com/p/as3corelib/" target="_blank">as3corelib</a>, but none of them (MD5, SHA-1) fitted our needs. There is another great cryptography library out there and it is <a title="As3Crypto" href="http://code.google.com/p/as3crypto/" target="_blank">as3Crypto</a>; the problem is that it is a bit hard to get around, there is a lot to choose from. We settled on AES (Advanced Encryption Standard). After 2 hours of trying to get it to work, we found this great post on <a title="As3Crypto + PHP" href="http://groups.google.com/group/as3crypto/browse_thread/thread/eba4897dabc57cd6" target="_blank">Google groups</a> (about middle of the page). I am copying the content here to make it easier for people to find. I have to give all the credit for this post to Jason Foglia who posted his code.</p>
<p>Here is the As3 Class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">&nbsp;
package
<span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
        <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">ByteArray</span>;
&nbsp;
        <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">hurlant</span>.<span style="color: #006600;">crypto</span>.<span style="color: #006600;">symmetric</span>.<span style="color: #006600;">ICipher</span>;
        <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">hurlant</span>.<span style="color: #006600;">crypto</span>.<span style="color: #006600;">symmetric</span>.<span style="color: #006600;">IVMode</span>;
        <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">hurlant</span>.<span style="color: #006600;">crypto</span>.<span style="color: #006600;">symmetric</span>.<span style="color: #006600;">IMode</span>;
        <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">hurlant</span>.<span style="color: #006600;">crypto</span>.<span style="color: #006600;">symmetric</span>.<span style="color: #006600;">NullPad</span>;
        <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">hurlant</span>.<span style="color: #006600;">crypto</span>.<span style="color: #006600;">symmetric</span>.<span style="color: #006600;">PKCS5</span>;
        <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">hurlant</span>.<span style="color: #006600;">crypto</span>.<span style="color: #006600;">symmetric</span>.<span style="color: #006600;">IPad</span>;
        <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">hurlant</span>.<span style="color: #006600;">util</span>.<span style="color: #006600;">Base64</span>;
        <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">hurlant</span>.<span style="color: #006600;">util</span>.<span style="color: #006600;">Hex</span>;
        <span style="color: #0066CC;">import</span> com.<span style="color: #006600;">hurlant</span>.<span style="color: #006600;">crypto</span>.<span style="color: #006600;">Crypto</span>;
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CryptoCode <span style="color: #0066CC;">extends</span> Sprite
        <span style="color: #66cc66;">&#123;</span>
                <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">'simple-des-ecb'</span>;
                <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">key</span>:ByteArray;
&nbsp;
                <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> CryptoCode<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#123;</span>
                        init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
&nbsp;
                <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
                <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #0066CC;">key</span> = Hex.<span style="color: #006600;">toArray</span><span style="color: #66cc66;">&#40;</span>Hex.<span style="color: #006600;">fromString</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'TESTTEST'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">// can only be 8 characters long</span>
&nbsp;
                        <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>encrypt<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'TEST TEST'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                        <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>decrypt<span style="color: #66cc66;">&#40;</span>encrypt<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'TEST TEST'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
&nbsp;
                <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> encrypt<span style="color: #66cc66;">&#40;</span>txt:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
                <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">data</span>:ByteArray = Hex.<span style="color: #006600;">toArray</span><span style="color: #66cc66;">&#40;</span>Hex.<span style="color: #006600;">fromString</span><span style="color: #66cc66;">&#40;</span>txt<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
                        <span style="color: #000000; font-weight: bold;">var</span> pad:IPad = <span style="color: #000000; font-weight: bold;">new</span> PKCS5;
                        <span style="color: #000000; font-weight: bold;">var</span> mode:ICipher = Crypto.<span style="color: #006600;">getCipher</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>, <span style="color: #0066CC;">key</span>, pad<span style="color: #66cc66;">&#41;</span>;
                        pad.<span style="color: #006600;">setBlockSize</span><span style="color: #66cc66;">&#40;</span>mode.<span style="color: #006600;">getBlockSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                        mode.<span style="color: #006600;">encrypt</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
                        <span style="color: #b1b100;">return</span> Base64.<span style="color: #006600;">encodeByteArray</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
                <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> decrypt<span style="color: #66cc66;">&#40;</span>txt:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
                <span style="color: #66cc66;">&#123;</span>
                        <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">data</span>:ByteArray = Base64.<span style="color: #006600;">decodeToByteArray</span><span style="color: #66cc66;">&#40;</span>txt<span style="color: #66cc66;">&#41;</span>;
                        <span style="color: #000000; font-weight: bold;">var</span> pad:IPad = <span style="color: #000000; font-weight: bold;">new</span> PKCS5;
                        <span style="color: #000000; font-weight: bold;">var</span> mode:ICipher = Crypto.<span style="color: #006600;">getCipher</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>, <span style="color: #0066CC;">key</span>, pad<span style="color: #66cc66;">&#41;</span>;
                        pad.<span style="color: #006600;">setBlockSize</span><span style="color: #66cc66;">&#40;</span>mode.<span style="color: #006600;">getBlockSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                        mode.<span style="color: #006600;">decrypt</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;
                        <span style="color: #b1b100;">return</span> Hex.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span>Hex.<span style="color: #006600;">fromArray</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Here is the php class:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #990000;">Crypt</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$iv</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$iv_size</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">Crypt</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">key</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$key</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">algorithm</span> <span style="color: #339933;">=</span> MCRYPT_DES<span style="color: #339933;">;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mode</span> <span style="color: #339933;">=</span> MCRYPT_MODE_ECB<span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">iv_size</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mcrypt_get_iv_size</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">algorithm</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">iv</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mcrypt_create_iv</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">iv_size</span><span style="color: #339933;">,</span> MCRYPT_RAND<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> encrypt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$size</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mcrypt_get_block_size</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">algorithm</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pkcs5_pad</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$size</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">return</span> <span style="color: #990000;">base64_encode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mcrypt_encrypt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">algorithm</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mode</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">iv</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> decrypt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pkcs5_unpad</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">rtrim</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mcrypt_decrypt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">algorithm</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">key</span><span style="color: #339933;">,</span> <span style="color: #990000;">base64_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mode</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">iv</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> pkcs5_pad<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$blocksize</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$pad</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$blocksize</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #000088;">$blocksize</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">return</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">.</span> <span style="color: #990000;">str_repeat</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pad</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pad</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> pkcs5_unpad<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$pad</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ord</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#123;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pad</span> <span style="color: #339933;">&gt;</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strspn</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pad</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$pad</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$pad</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">return</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$pad</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Now if you use the encrypt method of one you can send the data to the other one and decrypt it in the other language if you use the same key. Works like a charm. There is a mention that the key can only be 8 characters long but I haven&#8217;t tested it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2009/as3crypto-and-php-what-a-fun-ride/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Gingerbread house builder &#8211; TELUS holiday 2008 card</title>
		<link>http://www.zedia.net/2008/gingerbread-house-builder-telus-holiday-2008-card/</link>
		<comments>http://www.zedia.net/2008/gingerbread-house-builder-telus-holiday-2008-card/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 19:42:25 +0000</pubDate>
		<dc:creator>zedia.net</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[as3corelib]]></category>
		<category><![CDATA[FileReference]]></category>
		<category><![CDATA[PrintJob]]></category>
		<category><![CDATA[PureMVC]]></category>
		<category><![CDATA[Rich Internet Application]]></category>
		<category><![CDATA[TELUS]]></category>
		<category><![CDATA[TweenLite]]></category>

		<guid isPermaLink="false">http://www.zedia.net/?p=306</guid>
		<description><![CDATA[Just a quick post, while it is still the time, to bring you to the Gingerbread house builder we did for TELUS. I think it is a pretty little piece of flash that is fun and will make you smile. As it is the costum with holiday cards, the deadline was really tight but I [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick post, while it is still the time, to bring you to the <a title="TELUS Gingerbread house builder" href="http://promotions.telus.com/en/holiday2008/" target="_blank">Gingerbread house builder</a> we did for TELUS. I think it is a pretty little piece of flash that is fun and will make you smile. As it is the costum with holiday cards, the deadline was really tight but I think we managed well. This small rich internet application is packed with features that if you don&#8217;t stop to look, you won&#8217;t notice.</p>
<p>First the send to friend option actually sends a picture of the gingerbread house you built which was very nice to program. I had to take a screenshot(bitmapData.draw) of the House MovieClip encode it in JPEG (using <a title="as3corelib" href="http://code.google.com/p/as3corelib/" target="_blank">as3corelib</a>) and send it to the server. Next nifty detail is the print version of the recipe which also includes a picture of your creation. It wasn&#8217;t something really complicated to do considering I mostly used the send to friend code and put it in a PrintJob. Lastly, to save the recipe to PDF, instead of simply doing a navigateToURL to the PDF location, which would have opened a new tab in the browser with the PDF in it, I used FileReference.download to pop the download window so that the file is directly downloaded.</p>
<p>Independently these attentions might not seem like much, but if you put it all together the user won&#8217;t notice it but he will still feel this is a better application, without knowing why. Don&#8217;t get me wrong, I&#8217;m am not saying that the <a title="TELUS holiday card" href="http://promotions.telus.com/en/holiday2008/" target="_blank">TELUS holiday card</a> is the best application out there; I am saying that paying attention to details is what makes the difference between a nice application and a great one.</p>
<p>In that sense, I think there are stuff we could have done better. Mostly sound wise, to emphasize the meerkat (that is the name of the current TELUS critter) sneaking to take a bite on your gingerbread house. I&#8217;m not good at all in audio and when it comes to it I need help, and sound is somewhat not needed to make a website / application functionnal and beautiful, so it is often forgotten. But I will make sure in following projects to give it the proper time.</p>
<p>As I always do here is a list of the libraries I used to build it:</p>
<ul>
<li><a title="TweenLite" href="http://blog.greensock.com/tweenliteas3/" target="_blank">TweenLite</a></li>
<li><a title="PureMVC" href="http://puremvc.org/" target="_blank">PureMVC</a> (didn&#8217;t think I needed it at first but used it anyway and I am  glad I did because we kept adding new features)</li>
<li><a title="as3corelib" href="http://code.google.com/p/as3corelib/" target="_blank">as3corelib (JPEG encoding)</a></li>
</ul>
<p>Well that&#8217;s it, enjoy your holidays, I surely will!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zedia.net/2008/gingerbread-house-builder-telus-holiday-2008-card/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

