On Porting from iPhone to Netbook with Flex

Code-Monkeys's picture

Flex for Cocoa Developers.

Ryan Green

So back in October of 2008 I had an idea. I was going to make games for kids. And I was going to make these games for the iPhone, because in 2008, the big news was Apple's ITunes AppStore. They had millions of ready customers eager to buy what independent developers had to offer. There was just one catch. My day job consisted of building software to run on Adobe Flash player. To build software for the iPhone, I needed to use Apple's development tools on Apple's platform using Apple's programming language.

Maybe, like me, you ponied up the cash for that brand new Mac Book Pro, paid your developer fee, spent a painful weekend cramming all the useful Cocoa and Objective-C knowledge your brain could safely hold and then a few weeks later your first App was born.

Perhaps, like me, you've also seen the portable and mobile software industry bloom into a vibrant and exciting space where real companies can be built to deliver innovative software to paying customers. But, as evidenced by reading this article, you've realized that to expand your App reach from all things iDevice to a rapidly expanding and diverse marketplace, you're faced with a dilemma.

Unless you've built your App using a meta-framework, that is a set of software building blocks that make it easy to port your software from one operating system or hardware device to another with minimal effort and that you've built that software with an Apple blessed meta-framework, you must take time to rewrite your software for each device individually. That's a lot of rewrites and potentially a lot unnecessary time and money spent by your small business.

This article series aims to introduce the Cocoa/Objective-C developer to the Flex SDK on the Adobe Flash Platform.

Like Cocoa, Flex is a software development platform which provides developers with a set of developer tools, software building blocks and integrated runtimes upon which developers can rapidly assemble and distribute software.

Cocoa applications are distributed for use on Mac OS X and iOS runtimes. Flex applications are distributed for use on the Flash runtime.

The Flash runtime is a virtual machine which allows Flash-based applications to run in the Flash Player web-browser plug-in or the Adobe Integrated Runtime (AIR) which is designed to take Flash-based applications outside of the browser. This allows AIR applications to take advantage of lower level APIs not typically available inside a browser security sandbox. The Flash Player and AIR products are designed to allow a developer to distributed the same compiled executable to multiple operating systems, including Windows, Linux, OS X, Solaris and Android and devices such as PCs, laptops, netbooks, tablets, internet televisions and mobile phones.

Where as Cocoa applications are built using Obj-C/C/C++ and often employ Interface Builder for assembling UI views, Flex-based applications are written in ActionScript 3 (an object-oriented scripting language based on the ECMA 262 standard.) UI views are often assembled using MXML (an XML based markup language) or tools such as Flash Builder, Flash Catalyst, or Flash CS5.

In the comparison chart provided beneath this post, I've outlined some of the most prominent APIs available in the iOS/Cocoa and Flex 4 software development kits. I recommend visiting the provided links to reference materials in order to familiarize yourself with the Flex 4 SDK.

My goal in introducing you to Flash as a Platform in this series is two-fold. First, my hope is that you see that Adobe Flex 4 is a realistic alternative to the iPhone and Cocoa SDK. Second, I hope to give you the strategy and technical knowledge necessary to prepare your application for delivery on devices including Atom-based netbooks, tablets and mobile devices, and emerging marketplaces like the Intel AppUp Store!

  Apple Cocoa

Adobe Flex

Development Environment XCode IDE, Interface Builder Flex/Flash Builder IDE
Software Frameworks    
User Interface
Provides core layout and UI controls used to layout content and provide the ability for the user to interact with software.
UIKit

mx.container, mx.controls, spark.components, spark.layouts, mx.accessibility

Effects/Animation
Provides 2d and 3d animation effects for transitioning between UI elements on the display.
CoreAnimation mx.effects, spark.effects, mx.geom
Foundation
Provides core data types and file access apis
Foundation Global Functions, mx.collections, flash.filesystem (AIR Only)
Network
Provides ability to make network requests over various protocols.
CFNetwork mx.rpc.http, mx.rpc.remoting,
air.net (Sockets (Air Only))
,
Graphics
Provides drawing apis, image support, and graphic photoshop-like effects and filters.
CoreGraphics, OpenGLES flash.display, mx.graphics, spark.filters, mx.graphics.shaderClasses
Media
Provides APIs for sound and video playback.
CoreAudio, MoviePlayer flash.media
Misc.
Miscellaneous often device specific APIs.
CoreData, CoreLocation

flash.desktop (Command Line (AIR Only)),
flash.sensors (GeoLocation (AIR Only))
,
flash.data (SQL Lite (Air Only))

Runtimes OS X, iPhone, iPad, iPod Touch

Flash Runtime
Supports Windows, OS X, Linux, and Solaris

Mobile Flash Runtime (in 2010)
Looking to target many mobile devices including Android, WebOS, Blackberry, and Symbian.
iPhone support is available now in Flash CS5 but is currently being blocked by Apples Developer Agreement

Stay tuned for more information as I dive deeper into this series.

4.5
Average: 4.5 (4 votes)
12Kviews

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Posted On : June 25, 2010 - 11:41
Offline
Last seen: 1 year 46 weeks ago
Joined: Jun 25 2010
Points: 5

Hello

Posted On : July 8, 2010 - 14:46
Offline
Last seen: 2 days 18 hours ago
 Brown Belt
Joined: May 19 2010
Points: 8915

Has anyone looked at moving from an app written for Windows on an Atom to the Cisco Cius? The latter is Atom-based but runs Android.
As far as we know, no Mono (yet) for Android

Posted On : July 8, 2010 - 16:03
Code-Monkeys's picture
Offline
Last seen: 1 week 19 hours ago
 Black Belt (Community Leadership) Brown Belt
Joined: Dec 2 2009
Points: 3756

That's a great idea Mark. The Cius looks like a cool product and of course Android has a ton of buzz right now. I'm not aware of anybody working on those lines though...perhaps it's you own gold mine. ;)

Opportunity aside though, I think you'll find Intel really behind the MeeGo OS, particularly since Computex.

Posted On : August 8, 2010 - 20:41
Offline
Last seen: 39 weeks 2 days ago
Joined: Jun 15 2010
Points: 707

Flex is a noble idea, but it doesn't even have native support on the Android (the Flash Android beta currently only supports Flash Professional swf's not Flex..) - Flex "in-the-browser" as .swf is missing webcam and mic capabilities (you might as well just use Javascript to write your app). Also, even using Flex, I'm still not seeing a way around having to rewrite all my Objective C apps to Actionscript...

Posted On : August 8, 2010 - 20:43
Offline
Last seen: 39 weeks 2 days ago
Joined: Jun 15 2010
Points: 707

On another point, developing a Flex app for Intel AppUp will cost you around $800 to buy a security certificate - so, budget in both time and money to port your app and also buy the certificate.

Posted On : August 9, 2010 - 11:16
Code-Monkeys's picture
Offline
Last seen: 1 week 19 hours ago
 Black Belt (Community Leadership) Brown Belt
Joined: Dec 2 2009
Points: 3756

Hi Yosun. Thawte offers Air code signing certificates for $299, not $800 (which I think is close to VeriSign's price) and while that's not free, it's certainly a reasonable investment. What's more, you only need to buy one certificate for your whole company and it can sign as many apps as you build.

What's more, you really don't NEED a certificate at all. If you want to go lowball it's totally legit. Your app will say it's from an unknown vendor but I think for a lot of folks, that's not a big deal.

That said, from our perspective, if you're getting into this space with the notion of making a few bucks then the cost of a certificate is a small price to pay for the added credibility. I can't say I see it as a genuine barrier.

Posted On : August 9, 2010 - 12:01
Offline
Last seen: 18 weeks 1 day ago
 Green Belt
Joined: Jan 10 2010
Points: 310

Hi Yosun,

I do believe that the Flex SDK is not recommended for use on Android, however, I do not believe this to be a limitation of AIR or Flash 10.1 on the Android but is solely a User Experience and Memory Management consideration.

The Flex SDK is currently optimized for the desktop and as such, does not handle memory as tightly as an SDK built for a mobile phone. Also, the User controls were built for Keyboard/Mouse interaction and do not behave as well with multi touch on a small screen. Adobe has stated that their next SDK (version 5, codenamed Hero) will introduce mobile UI controls optimized for memory management, touch user interaction and limited screen real estate.

http://opensource.adobe.com/wiki/display/flexsdk/Hero

While I have not had a chance to do Flex/Flash development on Android, I did a quick search on google and found a video depicting Flex built on an android device that I'd recommend checking out.

http://www.jamesward.com/2010/05/21/flex-on-android-in-flash-player-and-...

Also, Flex "in-the-browser" requires that you use a Media Server to capture video / audio from Flash, however, with the introduction of AIR 2 (which will soon be out of beta on the AppUp store), you have the ability to capture and save sample audio data locally (AIR only not in the mobile browser). Here is an article I found on audio capture with the microphone using AIR 2.

http://www.adobe.com/devnet/air/flex/articles/using_mic_api.html

As far as video is concerned, there is no direct API for local non-server side video capture, however you can capture bitmap data from a camera.

Now lastly to your point about rewriting Objective-C in Action script. Yes, unfortunately you will have to do that. My goal in this article series is to show you that the path to porting Obj-C to action script isn't as foreign a concept as you might think at first glance. Flash development today is not the same as it was 5 years ago. It is now possible to approach the construction of a Flash/Flex application the same way you'd approach any software development project. You are able to practice good Object Oriented principles and the SDK is very mature, however, there are limitations and you'll have to evaluate if flash is the best option for the requirements of your project.

-Ryan

Posted On : August 9, 2010 - 12:07
Offline
Last seen: 18 weeks 1 day ago
 Green Belt
Joined: Jan 10 2010
Points: 310

Here is confirmation that while Flex is not recommended at this point, it is not prohibited.

http://labs.adobe.com/technologies/air2/android/

*snip
- Can I develop AIR applications for Android in the prerelease program using Flash Builder 4 and/or Flex 4?

The Flex 4 framework has not yet been optimized for mobile devices. However, advanced developers who are familiar with creating ActionScript-only AIR projects in Flash Builder can package those projects for Android using the adt command-line tool in the prerelease AIR for Android SDK. For more information on adt, please refer to the prerelease SDK documentation. If you encounter difficulties with this workflow, let us know through the forums.

We're currently working on creating a highly productive, cross-platform solution for mobile development using Flash Builder and Flex. If you sign up for the AIR for Android prerelease, we'll keep you informed of our progress. For more information, please see the Flex Mobile Framework content on Adobe Labs.

Posted On : October 9, 2010 - 01:49
cg.meenakshi (not verified)

Thanks,
it is very interesting presently im a sr.flex developer working wth winntelsystemspvt ltd.
but i want to know more abut the iphone app..im vry much interested in apples developer but reading details of what s/w req.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.