20 x tips to better optimize your flash content

Download 20 x Tips to better Optimize your Flash content

If you can't read please download the document

Post on 27-May-2015




0 download

Embed Size (px)


20 x Tips to better Optimize your Flash content


  • 1. 20 x Tips to betterOptimize your Flash content @EladElrom

2. #1: Flash Player 10.1out of the box optimization Instance Management Screensaver ModeNativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE; GPU Hardware Accelerationallows bitmap blittingstops using software (CPU) rendering altogether 3. #2: Profiling ur App Open Source Benchmark Flash BuilderProfiler - Tools RateFlash Benchmark 4.1 System FlexUnit 8: - Profiler Profiling withMonitor Frame FrameStats Benchmark AS3Grant Skinnershttp://www.kongregate.com/games/SnailsAnimation/flash-benchmark-08 http://jpauclair.net/flashpreloadprofiler/or http://www.timo-ernst.net/misc/riabench-start/ 4. #2: Profiling ur App OHHH. I almost forgot!!! you can just do: getSizeto find out the memory size of an object 5. #3: Architecting Micro-architecture frameworks? 6. Tip #4: I/OStrongRTMP.the data with AMF on client and AMF, lazy loading James Wards tool toUse 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 keepingsmooth 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 GCwill do his job correctly: Set weekly references - where possible:addEventListeners and Dictionary classes. Dont keep references - nulling objects withevents dont 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 playerinterrupt the starts Event.RENDER Final user code is executedwork 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: 68Use lowConstructor code of children executed: 276Player renders changes display list: possible) overTextField, SimpleButton (when 168 mx:Text Spark. It will require more coding but haloimprove performance.SpriteandwillConstructor code of children executed: 743 Player renders changes display list: executed: 399Constructor code of children 685Avoid using TLF - when possible. UIComponent s:LabelUse Halo components over Spark components.Constructor code of children executed: 1136 Player renders changes display list: executed: 1078Constructor code of children 198 use SpriteWhen creating custom componentsover MovieClip and UIComponent over Group Group s:RichText Constructor codegraphics its recommended to useWhen creating of children executed: 416Player renders changes display list: executed: 1195Constructor code of children 3224Shape display object. 13. Tip #11: Avoid expensiveoperations Bitmap filters and perspective distortion Frequently-updated Text 14. Tip #12: Decreasing execution time Primitives vs generic objectif...else statements Use strict modeTyping over generic objects Flex related tipsLoops Use e4x with caution Array vs ByteArray vs Vector Increasing rendering speed Callbacks andas BitmapData or BitmapManual cache events Regex as bitmap matrixCache and search string DatabindingSet all children caching policy Check the status of all childrenSealed vs. dynamic classes 15. Tip #13: Avoiding initializing andreference to unused classes 16. Tip #14: Set redraw regionto min 17. Tip #15: Reducing swffile size Limit font unicode-range Implement RSL in your project - RuntimeShared Libraries Load assets on runtime and reduce assets filesize Export Release Build Using strict mode 18. #16: Use Tools to reduce swffile size Apparat SWF Optimizer 19. Tip #17: Splitting apps into modules 20. Tip #18: Reuse objects - Object pooling 21. Tip #19: Working withexternal 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 benchmarkand memory usage when writing your code. Write code first: create your application andafter its running, take time to optimize. 23. Q&A http://elromdesign.com/blog eladelrom-preso.googlecode.com/files/OptimizeFlashContnet.pptx http://www.slideshare.net/eladnyc @EladElrom 24. 24