Yesterday, I had the chance to speak at the FFK10 conference in Germany. Initially, Mark Doherty should have presented the session on “Best practices for mobile development with the Flash Platform“, but, due to administrative issues, he couldn’t make it. It was a kind of challenge to understand this wide topic. Fortunately, I’ve found a lot of significant resources:
- To understand how to optimize your flash code, the reference is the white paper written by Thibault Imbert (http://www.bytearray.org/?p=1363). I figured out, reading this public book, that the main issues are coming from the rendering engine of the Flash Player. You really need to optimize the graphical assets of your Flash applications. The good news, is that the optimization tricks are really easy to understand and apply to your existing code.
- This article on the Adobe Developer Connection portal really helped me to deeply understand the behavior of the new Flash Player 10.1, the one that will be embedded on smartphones: http://www.adobe.com/devnet/flashplayer/articles/fplayer10.1_hardware_acceleration.html
- I also encourage you to follow the Slider project (Flex on mobile). http://labs.adobe.com/technologies/flex/mobile/
- Finally, I love the post of Christian Cantrell who developed a game that modify its layout regarding the size of the screen (which is a big challenge for mobile applications). http://blogs.adobe.com/cantrell/archives/2010/04/one_application_five_screens.html
Here are some tips:
-One key to understanding how to improve application performance is to understand how the Flash Platform runtime executes code. The runtime operates in a loop with certain actions occurring each “frame.” A frame in this case issimply a block of time determined by the frame rate specified for the application. Keep SWF frame rate as low as possible. If necessary, set the frame rate of the Stage dynamically as needed. Avoid high-rate ActionScript timers; also avoid using many different timers in the same project. BTW, Flash Player 10.1 RC limits the FPS to 60.
- Another simple way to optimize memory is to reuse objects and avoid recreating them whenever possible.
- Even when removed from the display list, the movie clip still dispatches the Event.ENTER_FRAME event. The movie clip still runs, but it is not rendered. To handle this situation correctly, listen to the proper events and remove event listeners, to prevent CPU-intensive code from being executed, check my slides.
- Consider bitmaps versus vectors. I’ve shown to the audience a benchmark application that demonstrates the good usage of the cacheAsBitmap property. My advice is the following. If you manipulate graphical elements using the X and Y axis only, please set the cacheAsBitmap property to true. It will dramatically improve the performances of your applications. Transparency is very expensive, avoid the alpha channel, avoid filters and blend modes. If you use the rotation property, don’t use cacheAsBitmap, but the Draw sample detailed here: http://www.bytearray.org/?p=290
- Video: On most mobile phones, software decoding of H.264 will often be below 10 fps. In the set of devices that support GPU-based H.264 decoding, not all will support all H.264 profiles and features. Support may be limited to baseline profile, or main profile in limited screen resolutions (such as 640 × 480 and lower). Most mobile devices can decode only one H.264 stream at a time. Additional streams will be decoded in software and may play back with very low frame rates.



Haha, i absolutely LOVE the 5th slide !