Adobe Air for Android: IPhone goodbye! ;)
Browse and load images from your phone library
Wow!!! Finally Adobe Flash on my phone… again.
I was waiting for it from the first Flashlite version on Nokia S60.
Infact, after the previous FlashLite experience, Adobe is working on the Adobe AIR version for mobile devices available on all Android phones with OS > 2.2 (the last version in this moment, codename Froyo)
Now it’s still in a beta, so it’s not officially available on your Flash CS5, but it will be available soon.
I want remember you that from this Android OS version (2.2) you can also view Flash content in your web browser (in other words Flash inside HTML pages) and what can I also say? IPHONE bye bye… forever ; )
Another interesting note is that Adobe is also working on a mobile version of the Flex framework, but I have not a lot of news about it (checks Adobe Labs )
Furthermore, Android will be integrated in different devices, from phones to tablet, and i’m reading something about SONY TV and much more…
Wow.. i’m so exited… a new big market is borning for all Flash / Flex developers.
So, this summer i bought my first Android phone (i have choosen the Google/HTC Nexus One, really a great phone) and I spent some days playing around it and testing the first available ActionScript features for Android in Flash CS5.
Here the application screenshot and video:
Following a simple ActionScript 3.0 / Flash CS5 script to load images from the phone gallery.
package { import flash.display.*; import flash.events.*; import flash.filesystem.File; import flash.media.CameraRoll; import flash.media.MediaPromise; import fl.transitions.Tween; import fl.transitions.easing.*; public class AIRLoadImageFromGallery extends Sprite { public var loader:Loader; public var selectedMedia:MediaPromise; public var cam:CameraRoll; public var myBitmap:Bitmap; public var myBitmapData:BitmapData public function AIRLoadImageFromGallery(){ loadBtn.addEventListener(MouseEvent.MOUSE_DOWN, browseImage); loadBtn.mouseChildren = false; } /** * Browse image opening the Media Gallery */ public function browseImage(event:MouseEvent):void { //txtLogs.text = "Logs go here...n"; outputTxt.text = ""; if(CameraRoll.supportsBrowseForImage){ cam = new CameraRoll; cam.addEventListener(MediaEvent.SELECT, onMediaSelect); cam.addEventListener(Event.CANCEL, eventsHandler); cam.addEventListener(ErrorEvent.ERROR ,eventsHandler); cam.browseForImage(); } else outputTxt.text = "This feature is not supported on this platform"+"n"; } public function eventsHandler(e:Event):void { trace(e.type+"n"); } /** * On Image selection */ public function onMediaSelect(e:MediaEvent):void{ selectedMedia = e.data as MediaPromise; outputTxt.text = selectedMedia.file.nativePath ; loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,eventsHandler); loader.loadFilePromise(selectedMedia); } /** * Loading handler */ public function completeHandler(e:Event):void { // Remove previous images if (myBitmap != null) { removeChild(myBitmap); } var originalWidth:Number = Bitmap(e.currentTarget.content).width; var originalHeight:Number = Bitmap(e.currentTarget.content).height; // Create a bitmap from the loaded image myBitmapData = new BitmapData(originalWidth,originalHeight); myBitmap = new Bitmap(myBitmapData);; myBitmap.bitmapData = Bitmap(e.currentTarget.content).bitmapData; // Display the image fullscreen mantaining its aspect ratio myBitmap.width = this.stage.stageWidth; myBitmap.height = (originalHeight * this.stage.stageWidth) / originalWidth; // Position the image to x:0 y:5 myBitmap.x = 0; myBitmap.y = 0; addChild(myBitmap); } } }
Naturally, to put in place this script, you have to create an AIR for Android Flash files with two object: a MovieClip with instance name ‘loadBtn’ (the button) and the dynamic text ‘outputTxt’ to display messages
Check this great tutorial from Lee Brimelow to understand how Android and Flash work together





















Ciao Fabio!
Great tutorial Thanks!
-Leo
Leave your response!