One of the worst problem that any developer have to face is the performance of his applications. There are many factor contributing to a bad performance, one of them is graphic rendering.
Depending of what you’re doing, there’s a single line of code that solves this problem.
stage.quality = StageQuality.LOW
When you set the stage quality as low, you tell flash to render all vectors without anti-alias. This increases the application performance a lot. However this can makes your application looks like a crap depending of how you built it. There is a few things you can do to balance performance and visual quality.
The first thing you can do is set your text alias as ADVANCED or if it’s a static text Anti-alias for readability.
Another tip is use bitmaps instead of vectors. Of course you must choose wisely whose graphics need to have a good quality and the size of them. Also, you can change you image quality at the properties panel to get a smaller file. Although you need to be carefull with this, because your bitmaps wont smooth if you rotate or scale them.
I didn’t research why exactly bitmaps don’t mess up when the stage quality is set to low, but I think it is because flash don’t need to calculate what color every pixel when they are displayed, all colors are already defined by the bitmap data.
With this thought, I created a high quality container class, called HQContainer, that renders all children at the quality you want (low, medium, high, best).
I have a 1000 boxes rotating. 990 of them are blue and have .05 of opacity. 10 of them are red and have a MouseEvent listener added.
Basicly what happen behind it is that a Bitmap is created for each instance of this class, then on enter frame the stage quality is changed to the specified quality, the container is drawn and the stage quality is changed back. This is a hard cpu process, so you must choose wisely which objects must have a high quality.
Here is a performance test.
See that the fps is not something we could call good, but if we set the stage quality as low, things get a lot faster.
Due it’s opacity, the blue boxes don’t mess up as the red ones. But if we add them to a HQContainer the result is totaly diferent.
Of course in real life we wont do rotating boxes to our clients, but this example can show you how get a good quality with good performance.
Tags: as3, performace, source, tip



Brother, estou muito content com este seu projeto do Blog, está ficando realmente muito interessante a cada novo post.
Continue o bom trabalho!
Valeu cara!! Fico feliz de estar fazendo algo utíl…hehehe
Muito bom o post, parabéns!