ACTIONSCRIPT 3:COMMON OPTIMIZATION         Teerasej Jiraphatchandej  User Group Manager, Thai Adobe Developer Community   ...
Understand:CODEEXECUTION                                    Create by Teerasej Jiraphatchandej.       All rights reserved ...
CODE EXECUTION                                           24 fps                               Create by Teerasej Jiraphatc...
CODE EXECUTION•   Phase 1: event & enter frame•   Phase 2: rendering                                           Create by T...
CODE EXECUTIONPhase 1                                    Phase 2                                 Create by Teerasej Jiraph...
CODE EXECUTIONPhase 1                                    Phase 2                                 Create by Teerasej Jiraph...
CODE EXECUTIONPhase 1                                    Phase 2                                 Create by Teerasej Jiraph...
CODE EXECUTIONPhase 1                                                 Phase 2                                 Create by Te...
CODE EXECUTION< 24 fps                                  Create by Teerasej Jiraphatchandej.     All rights reserved . Thai...
Guideline:OPTIMIZATION                                     Create by Teerasej Jiraphatchandej.        All rights reserved ...
Create by Teerasej Jiraphatchandej.AVOID OPTIMIZATION EARLY                                                           All ...
Create by Teerasej Jiraphatchandej.SOME OPS, NOT NOTICEABLE                                                     All rights...
Create by Teerasej Jiraphatchandej.OPTIMIZED IS HARD MAINTAIN                                                          All...
Create by Teerasej Jiraphatchandej.DON’T USE FILTER                                                           All rights r...
Create by Teerasej Jiraphatchandej.AVOID MOTION                                                          All rights reserv...
Create by Teerasej Jiraphatchandej.PERFORMANCE TEST                                                     All rights reserve...
Tips 1:USEBITMAP                                       Create by Teerasej Jiraphatchandej.          All rights reserved . ...
FLASH CS6 BITMAP•   Normal•   Cache as Bitmap•   Export as Bitmap                                           Create by Teer...
CACHE AS BITMAP•   Possible use more memory than vector.•   Apply to each graphic, not animated movie clip.•   Don’t use w...
EXPORT AS BITMAP•   Good for static object•   Increase SWF file size.                                            Create by...
Tips 2:CONSERVINGMEMORY                                       Create by Teerasej Jiraphatchandej.          All rights rese...
DISPLAY OBJECT TYPE•   Shape•   Sprite•   MovieClip                                          Create by Teerasej Jiraphatch...
SHAPE                             Create by Teerasej Jiraphatchandej.All rights reserved . Thai Adobe Developer Community ...
SPRITE                             Create by Teerasej Jiraphatchandej.All rights reserved . Thai Adobe Developer Community...
MOVIE CLIP                             Create by Teerasej Jiraphatchandej.All rights reserved . Thai Adobe Developer Commu...
PRIMITIVE•   Around 4 - 8 KB•   String depend on used•   Can’t optimize more                                         Creat...
Tips 3:REUSINGOBJECT                                       Create by Teerasej Jiraphatchandej.          All rights reserve...
REUSING OBJECTfor ( ... ) {  var a : Object = new ...}                                  Create by Teerasej Jiraphatchandej...
REUSING OBJECTvar a:Object;for ( ... ) {  a = new ...}                                  Create by Teerasej Jiraphatchandej...
Tips 4:FREE MEMORY                                       Create by Teerasej Jiraphatchandej.          All rights reserved ...
GARBAGE COLLECTOR                                Create by Teerasej Jiraphatchandej.   All rights reserved . Thai Adobe De...
GARBAGE COLLECTOR  Stage           MovieClip                                                  MovieClip                   ...
GARBAGE COLLECTOR       Stage                MovieClipGC                                                     MovieClip    ...
FORCE GC TO WORK•   remove all reference to object    •   Remove event listener    •   Set object to null                 ...
FORCE GC TO WORKobj.removeEventListener();                                   Create by Teerasej Jiraphatchandej.      All ...
BEWARE!!•   Set object to null, not force GC to run immediately•   GC use CPU and memory in running.•   Adobe AIR force GC...
Tips 5:DEACTIVATE                                       Create by Teerasej Jiraphatchandej.          All rights reserved ....
ACTIVATE AND DEACTIVATE•   Object that removed from stage, doesn’t be destroyed    immediately•   Use framework to optimiz...
FORCE GC TO WORK  Event.ADD_TO_STAGEEVENT.REMOVE_FROM_STAGE                                  Create by Teerasej Jiraphatch...
Tips 6:DISABLEMOUSE                                       Create by Teerasej Jiraphatchandej.          All rights reserved...
DISABLE MOUSE• obj.mouseEnable                = false;• obj.mouseChildren                    = false;                     ...
GUIDELINE SUMMARY•   Don’t optimize too early•   Some optimization will not be noticeable by user•   Don’t use filter•   A...
TIPS SUMMARY•   Use BitMap•   Conserving memory•   Reusing object•   Free memory•   Activate & Deactivate•   Disable Mouse...
TEERASEJJIRAPHATCHANDEJUSER GROUP MANAGERTHAI ADOBE DEVELOPER COMMUNITY     teerasej@gmail.com     teerasej     thaiadc.com
Upcoming SlideShare
Loading in …5
×

Common optimization for Actionscript 3

1,329 views
1,242 views

Published on

Teerasej Jiraphatchandej's presentation on summarize optimization technique for using Adobe Flash Platform on low-tier hardware like mobile device (iOS, Android, Windows Phone, BlackBerry 10).

This presentation went first public at ITSC, Chiang Mai University, Thailand (6-9 Nov)

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,329
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Common optimization for Actionscript 3

  1. 1. ACTIONSCRIPT 3:COMMON OPTIMIZATION Teerasej Jiraphatchandej User Group Manager, Thai Adobe Developer Community Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  2. 2. Understand:CODEEXECUTION Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  3. 3. CODE EXECUTION 24 fps Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  4. 4. CODE EXECUTION• Phase 1: event & enter frame• Phase 2: rendering Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  5. 5. CODE EXECUTIONPhase 1 Phase 2 Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  6. 6. CODE EXECUTIONPhase 1 Phase 2 Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  7. 7. CODE EXECUTIONPhase 1 Phase 2 Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  8. 8. CODE EXECUTIONPhase 1 Phase 2 Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  9. 9. CODE EXECUTION< 24 fps Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  10. 10. Guideline:OPTIMIZATION Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  11. 11. Create by Teerasej Jiraphatchandej.AVOID OPTIMIZATION EARLY All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com http://www.flickr.com/photos/23912215@N02/4112230589/
  12. 12. Create by Teerasej Jiraphatchandej.SOME OPS, NOT NOTICEABLE All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com 6264966_82f69fd170_b.jpg from flickr
  13. 13. Create by Teerasej Jiraphatchandej.OPTIMIZED IS HARD MAINTAIN All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com http://www.flickr.com/photos/nigelmeng/636115602/
  14. 14. Create by Teerasej Jiraphatchandej.DON’T USE FILTER All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com http://www.flickr.com/photos/kwerfeldein/1693519458/
  15. 15. Create by Teerasej Jiraphatchandej.AVOID MOTION All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com http://www.flickr.com/photos/saxonmoseley/106432807/
  16. 16. Create by Teerasej Jiraphatchandej.PERFORMANCE TEST All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com 1717925528_1aba213644_o.jpg from flickr
  17. 17. Tips 1:USEBITMAP Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  18. 18. FLASH CS6 BITMAP• Normal• Cache as Bitmap• Export as Bitmap Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  19. 19. CACHE AS BITMAP• Possible use more memory than vector.• Apply to each graphic, not animated movie clip.• Don’t use with container that has animating children Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  20. 20. EXPORT AS BITMAP• Good for static object• Increase SWF file size. Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  21. 21. Tips 2:CONSERVINGMEMORY Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  22. 22. DISPLAY OBJECT TYPE• Shape• Sprite• MovieClip Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  23. 23. SHAPE Create by Teerasej Jiraphatchandej.All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  24. 24. SPRITE Create by Teerasej Jiraphatchandej.All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  25. 25. MOVIE CLIP Create by Teerasej Jiraphatchandej.All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  26. 26. PRIMITIVE• Around 4 - 8 KB• String depend on used• Can’t optimize more Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  27. 27. Tips 3:REUSINGOBJECT Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  28. 28. REUSING OBJECTfor ( ... ) { var a : Object = new ...} Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  29. 29. REUSING OBJECTvar a:Object;for ( ... ) { a = new ...} Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  30. 30. Tips 4:FREE MEMORY Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  31. 31. GARBAGE COLLECTOR Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  32. 32. GARBAGE COLLECTOR Stage MovieClip MovieClip MovieClip MovieClip MovieClip Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  33. 33. GARBAGE COLLECTOR Stage MovieClipGC MovieClip MovieClip MovieClip MovieClip Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  34. 34. FORCE GC TO WORK• remove all reference to object • Remove event listener • Set object to null Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  35. 35. FORCE GC TO WORKobj.removeEventListener(); Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  36. 36. BEWARE!!• Set object to null, not force GC to run immediately• GC use CPU and memory in running.• Adobe AIR force GC using: System.GC(); Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  37. 37. Tips 5:DEACTIVATE Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  38. 38. ACTIVATE AND DEACTIVATE• Object that removed from stage, doesn’t be destroyed immediately• Use framework to optimize performance Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  39. 39. FORCE GC TO WORK Event.ADD_TO_STAGEEVENT.REMOVE_FROM_STAGE Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  40. 40. Tips 6:DISABLEMOUSE Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  41. 41. DISABLE MOUSE• obj.mouseEnable = false;• obj.mouseChildren = false; Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  42. 42. GUIDELINE SUMMARY• Don’t optimize too early• Some optimization will not be noticeable by user• Don’t use filter• Avoid motion• Do performance test Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  43. 43. TIPS SUMMARY• Use BitMap• Conserving memory• Reusing object• Free memory• Activate & Deactivate• Disable Mouse Create by Teerasej Jiraphatchandej. All rights reserved . Thai Adobe Developer Community . http://thaiadc.groups.adobe.com
  44. 44. TEERASEJJIRAPHATCHANDEJUSER GROUP MANAGERTHAI ADOBE DEVELOPER COMMUNITY teerasej@gmail.com teerasej thaiadc.com

×