Few months ago, I was involved in a project for Procter & Gamble called as Mexx Attracts – Sexy meets Smart which was a match-making microsite where one would select one of his freind’s pictures and match with their own self through a questionnaire about personalities but much like most flash developers, all I really cared about was the scope of the project and an opportunity for me to learn from/experiment with new technology. And it seriously was one great experience technically.
As with most of typical match-making microsites (did I just say typical? :)), based on the answers, users are led to see one of the five situations showing as a video where their heads are masked to the role-playing characters. The final situation varies depending on the answers; it can be funny, plain boring, a marriage ceremony or even a fight.
For this project, I had to get into using ByteArray class to store the bitmap data of a movieclip placed on stage and pass this data on to a php file which would store the image on filesystem and create and store a respective ID in a database as well.
Upon googling, some of the links came in very handy understanding the whole flash-to-filesystem-storing issue and I got to know a few more benefits of using ActionScript 3.0. One of those useful links was this, and obviously the JPGEncoder class of adobe’s as3corelib package did the magic for me.
It all went well, the site went live and received some good response overall.
But just recently I was asked to update the code to pass on the bitmap bytearray data to HTML rather than a PHP, why?, because for the facebook part of this microsite was having a bit of an issue storing the image on the filesystem. The whole back-end application works in a way that first the HTML form fields are submitted to a PHP, PHP then creates the database fields and then flash calls another PHP to store the image to the filesystem with an ID. But in the facebook application, flash call was made a lot earlier and since the PHP doesn’t get the required IDs fetched from the form-fields of the HTML, the file was not stored on the database and on filesystem. So to update that, we decided to pass on the flash image data to HTML/JS and then HTML/JS would take care of the calls since it will have all the data to pass on to PHP to store.
Now, upon googling again, I found out that the only format HTML understands for image source is in Base64 format and just after a few more queries, I was able to find out a good handy AS 3.0 class for conversion of ByteArray data to Base64 format which allows you to convert any String or ByteArray data to Base64 and vice versa.
So in all, it was a good experience for me to get a little more deep into ActionScript programming, to tackle a few complex tasks which may sound easy and to understand a few more concepts moving along.
Check out the live site, www.mexx-attracts.com.