I have built a few applications for Android using the Flex framework. It is a great framework and I can build, test, and publish apps very quickly. It takes productivity to the max.
However, I have noticed that some of my apps take a noticeable time to launch on my device for the first time. Even simple apps like QuickIP where all it does it check for external and wifi IP address. So I ran a few comparison tests between pure AS3 projects and Flex projects to see three things. Startup time, file (swf) size, and memory usage. All important on a mobile device. Here are the results.
Mobile Pure AS3
- Startup Time: 99ms
- SWF Size: 1.5kb
- Memory Usage*: 6.328mb
Mobile Flex mxml
- Startup Time: 653ms
- SWF Size: 2.839mb
- Memory usage*: 21.397mb
Memory usage is a sample taken after 5 seconds of the app being launched. All the apps are just code to test startup time and memory usage after 5 seconds. The Flex mobile project was a blank project. Each project launched a view that was run on my desktop, not on a device.
So how does this compare?
AS3 over Flex
- AS3 launches in 15.16% of the time it takes a Flex project
- AS3's file size is .05% of the Flex projects size
- AS3 uses 29.58% of the memory that a Flex project uses
As for the desktop, the numbers are closer to the same. Remember that I launched the mobile project on my desktop rather than on a device so the tests have a consistent test environment.
Desktop Pure AS3
- Startup Time: 96ms
- SWF Size: 1.5kb
- Memory Usage*: 6.184mb
Desktop Flex mxml
- Startup Time: 556ms
- SWF Size: 2.114mb
- Memory usage*: 19.021mb
As you can see the desktop Flex project is a little lighter on the resources than a comparable Mobile Flex app. I even did some tests on the desktop such as only using spark and no mx. I have even changed the WindowedApplication to just Application (no visible window as launch) and was able to get the startup time down to 450ms and only using ~15mb of ram. I tried to do tests with a Flex project's initial application file as a .as instead of a .mxml file but they were unsuccessful in launching a visible window. However just launching an initial .as instead of .mxml did make the Flex project have the same ~99ms startup time, ~1.5kb swf size, and ~6mb memory footprint.
So the question is... Is the speed of productivity in building an app on the Flex framework worth the loss of speed running the app? I guess it depends on what type of app you are building and what your user base is. The big difference between the Flex framework and pure As3 is components. You have to build all the components your self in pure AS3 projects. But how will productivity change for pure As3 projects after you already have a library of components built? What if you make all your assets and skin the Flex components anyway with bitmap or fxg assets? Do the components matter then?
These are the questions that I am asking my self currently. I am going to rebuild my QuickIP app with pure AS3 since it has all custom bitmap assets then compare the performance on my Android device and see if the time of development makes a noticeable jump in performance.