6. Tip #4: I/O•••StrongRTMP.the data with AMF on client and AMF, lazy loading James Ward’s tool to Use type Use whenever possible. server side to increase performance. benchmark and see the memory difference: http://www.jamesward.com/census/.
7. Tip #5: Manipulating swf Framerate• Reducing fps when your app is inactive• Increase the fps once the app is active againhttps://github.com/EladElrom/Flash-Optimizing-Tools• Increase fps while animation is playing toframerateManager:FrameRateOptimizer = create a morenew FrameRateOptimizer(and keeping smooth experience this, true ); a stack of all the animations being played to know when we can drop the fps.• Provide a cross platform API (Pure AS3, Flex, AIR)
8. Tip #6: Reduce memory usageMemory leaks due to listeners that have been set by us orsomeone else and never removed from memory:Solution: Listeners APImovieClip.addEventListener( listeners.type =MouseEvent.CLICK, listeners.handler = onClick );movieClip.addEventListener( listeners.type =MouseEvent.DOUBLE_CLICK, listeners.handler = onDoubleClick );listeners.removeAllListeners( movieClip );
9. Tip #7: Avoid memory leaksCall gc twice, or in AIR system.gc(): Ensure GC will do his job correctly:• Set weekly references - where possible: addEventListeners and Dictionary classes.• Don’t keep references - nulling objects with events don’t unhook them.
10. Tip #8: Update screen once per frameElastic Racetrack• Frame starts - Event.ENTER_FRAME• Frame actions executed - Event.FRAME_CONSTRUCTED • Avoid using updateAfterEvent,• End of Frame cycle - Event.EXIT_FRAME since it• Pre-render phasePlayer- and increases the player interrupt the starts Event.RENDER• Final user code is executed work load.• Player renders changes to display own using the • Handle invalidation on your• Cycle completed stage.invalidate() property
11. Tip #9: Decrease nesting
12. Tip #10: Reduce complexity• Shape level classes such as• TextField• Constructor code of children executed: 68 Use low Constructor code of children executed: 276 Player renders changes display list: possible) over TextField, SimpleButton (when 168• mx:Text Spark. It will require more coding but• haloimprove performance. Spriteand will Constructor code of children executed: 743• Player renders changes display list: executed: 399 Constructor code of children 685 Avoid using TLF - when possible.• UIComponent• s:Label Use Halo components over Spark components. Constructor code of children executed: 1136• Player renders changes display list: executed: 1078 Constructor code of children 198 use Sprite When creating custom components over MovieClip and UIComponent over Group• Group• s:RichText• Constructor codegraphics it’s recommended to use When creating of children executed: 416 Player renders changes display list: executed: 1195 Constructor code of children 3224 Shape display object.
13. Tip #11: Avoid expensive operations• Bitmap filters and perspective distortion• Frequently-updated Text
14. Tip #12: Decreasing execution time• Primitives vs generic object if...else statements•• Use strict mode Typing over generic objects•• Flex related tips Loops• Use e4x with caution• Array vs ByteArray vs Vector• Increasing rendering speed•• Callbacks andas BitmapData or Bitmap Manual cache events•• Regex as bitmap matrix Cache and search string• Databinding Set all children caching policy•• Check the status of all children Sealed vs. dynamic classes
15. Tip #13: Avoiding initializing and reference to unused classes
16. Tip #14: Set redraw region to min
17. Tip #15: Reducing swf file size• Limit font unicode-range• Implement RSL in your project - Runtime Shared Libraries• Load assets on runtime and reduce assets file size• Export Release Build• Using strict mode
18. #16: Use Tools to reduce swf file size• Apparat• SWF Optimizer
19. Tip #17: Splitting apps into modules
20. Tip #18: Reuse objects - Object pooling
21. Tip #19: Working with external assets• caching data in the memory• cache data on the local device• Image blitting
22. #20: be poactive & keep optimizing• Be Proactive: take into account benchmark and memory usage when writing your code.• Write code first: create your application and after it’s running, take time to optimize.