In ActionScript 3, using vector graphics is a guaranteed way to cause massive damage to the performance of your project.
Using a single Bitmap for all graphics by using .copyPixels() through its BitmapData object in place of all vector graphics will yield a ridiculous performance boost and is essential for people like myself developing games within Flash.
Beyond this I’m not really sure what the next major things that I should be targeting and attempting to optimize are. I do use a lot of the inbuilt trigonometry functions, but they don’t seem to affect it all that much. I know there are some libraries that optimize mathematics with approximation methods and similar, but so far I haven’t found these necessary.
Are there any other massive known points I should be looking at? I’m more referring to the inbuilt things that I should be careful of (like avoiding vector rendering) rather than how to improve my own coding style.
Documents I’ve found helpful are:
Some highlights:
Choose appropriate display objects
Use
getSize()to benchmark codeChoose appropriate primitive types to conserve memory
Reuse objects
Use object pooling
Free memory
Use bitmaps
Avoid filters, including filters processed through Pixel Bender
Use mipmapping to scale large images
Use Text Engine for read-only text,
TextFieldfor input textUse callbacks instead of events
Freeze and unfreeze objects on added / removed from stage
Use
Event.ACTIVATEandEvent.DEACTIVATEevents to detect background inactivityDisable mouse interaction when possible
Use Timers for non-animated content
Limit tweening
Use
Vectorvs.ArrayUse drawing API for faster code execution
Use event capture and bubbling to minimize event handlers
Paint pixels using
setVector()methodlock()andunlock()BitmapDatawhen using slow methods likesetPixel()orsetPixel32()Use
Stringclass methods instead of regular expressionsFor TextFields, use
apendText()instead of the+=operatorSquare bracket operator
[]can slow performance – store a reference in a local variableReduce number of function calls by moving code inline
Avoid placing content off-stage
Avoid using
alphapropertyUse lowest possible frame rate
Use bitmap caching for complex vector content
Set
cacheAsBitmapMatrixproperty when using cached bitmaps in mobile AIR appsUse
BitmapDataclass to create custom bitmap caching behaviorIsolate events such as
Event.ENTER_FRAMEin a single handlerUse the bitmap caching feature and the
opaqueBackgroundproperty to improve text rendering performanceEnable GPU hardware graphics acceleration
Favor using asynchronous versions of operations
Smooth shapes to improve rendering
Cache assets locally after loading them, instead of loading them from the network each time they’re needed
Use the
StageVideoclass to take advantage of hardware accelerationThe AAC audio format offers better quality and smaller file size than the mp3 format at an equivalent bit rate
Minimize code in constructors