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/.
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)
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 );
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.
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
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.
Tip #11: Avoid expensive operations• Bitmap filters and perspective distortion• Frequently-updated Text
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
Tip #13: Avoiding initializing and reference to unused classes
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
#16: Use Tools to reduce swf file size• Apparat• SWF Optimizer
Tip #19: Working with external assets• caching data in the memory• cache data on the local device• Image blitting
#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.