Rendering performance optimization

   Most of us are familiar with CPU consuming problem in Flash applications. There are cases, when you have nothing to do with, but in few cases you can use well known solution – cacheAsBitmap. It prevents object re-rendering in case a shape and content are never changed.

  There is a case when caching of Sprite object doesn't always solve the problem. What if your sprite contains different types of elements and all elements are static (no shape or position changes)? Does caching as bitmap of the Sprite will help to improve object rendering performance? The answer is yes, but there is a little nuance.

  The case – you have some Sprite with a lot of (thousands of) elements and any scrolling over the sprite causes to browser to "get in shock". Why so? Every movement of the object causes to flash to re-render the whole Sprite (including children elements) from the scratch. So you see as during the scrolling the CPU time jumps by tens of percents.

The solution is to cache the Sprite as bitmap, this suppose to stop re-rendering and to use cached bitmap - the snapshot of the sprite. Right? Wrong. If the Sprite contains movieClip objects, you have to cache as bitmap the main Sprite and every movieClip object always, one-by-one. So the caching function may be as following:


			private function cacheYourSprite(mySprite:Sprite):void
				for (var childsCounter:int=0; childsCounter < mySprite.numChildren; childsCounter++)
					if (mySprite.getChildAt(childsCounter) is MovieClip)
						(mySprite.getChildAt(childsCounter) as MovieClip).cacheAsBitmap = true;
				mySprite.cacheAsBitmap = true;


Best Regards and Good Application Performance,



Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at