Presentation is loading. Please wait.

Presentation is loading. Please wait.

20 x Tips to better Optimize your Flash

Similar presentations

Presentation on theme: "20 x Tips to better Optimize your Flash"— Presentation transcript:

1 20 x Tips to better Optimize your Flash content @EladElrom

2 #1: Flash Player 10.1 “out of the box” optimization Instance Management Screensaver Mode NativeApplication.nativeApplication.systemI dleMode = SystemIdleMode.KEEP_AWAKE; GPU Hardware Acceleration

3 #2: Profiling ur App Flash Benchmark 8: or Flash Builder Profiler Profiling with System Tools Grant Skinner’s Benchmark AS3 FlexUnit 4.1 Benchmark FrameStats - Monitor Frame Rate Open Source Profiler -

4 #2: Profiling ur App OHHH…. I almost forgot!!! you can just do: getSize to find out the memory size of an object

5 #3: Architecting Micro-architecture frameworks?

6 Tip #4: I/O AMF, RTMP. Use James Ward’s tool to benchmark and see the memory difference: Use lazy loading whenever possible. Strong type the data with AMF on client and server side to increase performance.

7 Tip #5: Manipulating swf Framerate Reducing fps when your app is inactive Increase the fps once the app is active again Increase fps while animation is playing to create a more smooth experience and keeping 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) framerateManager:FrameRateOptimizer = new FrameRateOptimizer( this, true );

8 Tip #6: Reduce memory usage Memory leaks due to listeners that have been set by us or someone else and never removed from memory: Solution: Listeners API movieClip.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 leaks Call 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 frame Elastic Racetrack Frame starts - Event.ENTER_FRAME Frame actions executed - Event.FRAME_CONSTRUCTED End of Frame cycle - Event.EXIT_FRAME Pre-render phase starts - Event.RENDER Final user code is executed Player renders changes to display Cycle completed Avoid using updateAfterEvent, since it interrupt the Player and increases the player work load. Handle invalidation on your own using the stage.invalidate() property

11 Tip #9: Decrease nesting

12 Tip #10: Reduce complexity Shape Constructor code of children executed: 276 Sprite Constructor code of children executed: 399 UIComponent Constructor code of children executed: 1078 Group Constructor code of children executed: 1195 Use low level classes such as TextField, SimpleButton (when possible) over halo and Spark. It will require more coding but will improve performance. Avoid using TLF - when possible. Use Halo components over Spark components. When creating custom components use Sprite over MovieClip and UIComponent over Group When creating graphics it’s recommended to use Shape display object. TextField Constructor code of children executed: 68 Player renders changes display list: 168 mx:Text Constructor code of children executed: 743 Player renders changes display list: 685 s:Label Constructor code of children executed: 1136 Player renders changes display list: 198 s:RichText Constructor code of children executed: 416 Player renders changes display list: 3224

13 Tip #11: Avoid expensive operations Bitmap filters and perspective distortion Frequently-updated Text

14 Tip #12: Decreasing execution time Primitives vs generic object Typing over generic objects Loops Array vs ByteArray vs Vector Callbacks and events Regex and search string Databinding Sealed vs. dynamic classes if...else statements Use strict mode Flex related tips Use e4x with caution Increasing rendering speed Manual cache as BitmapData or Bitmap Cache as bitmap matrix Set all children caching policy Check the status of all children

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.

23 Q&A 101-mobile-optimi.html 101-mobile-optimi.html flash-content-and-imp.html flash-content-and-imp.html @EladElrom

24 24

Download ppt "20 x Tips to better Optimize your Flash"

Similar presentations

Ads by Google