AS3 - Setting the stage quality PDF Print E-mail
Monday, 27 June 2011 16:08

Stage quality specifies which rendering qualitiy is used, controlling graphics anti-aliasing and bitmap smoothing.

User can change it right-clicking on your movie, from the Quality option, but sometimes it's useful to modify it in your script

To do it, we need to set the quality property of the stage. 

We have four possible options for our stage quality:

stage.quality

Effects

StageQuality.BEST Very high rendering quality: graphics are anti-aliased using a 4 x 4 pixel grid and bitmaps are always smoothed
StageQuality.HIGH High rendering quality: graphics are anti-aliased using a 4 x 4 pixel grid, and bitmaps are smoothed if the movie is static
StageQuality.MEDIUM Medium rendering quality: graphics are anti-aliased using a 2 x 2 pixel grid, but bitmaps are not smoothed
StageQuality.LOW Low rendering quality: graphics are not anti-aliased, and bitmaps are not smoothed

 

Text is affected only if it is set to "Anti-alias for animation".

 

Let's see a practical example. Here, you can see the effect of the various options:

 

The buttons are not affected because their text is set to "Anti-alias for readability".

I've simply put four buttons on the stage and wrote this as the document class:


	 

	package  {

	 

	import flash.display.StageQuality;

	import flash.display.Sprite;

	import flash.display.StageQuality;

	import flash.events.MouseEvent;

	 

	public class StageQualityTutorial extends Sprite{

	 

	public function StageQualityTutorial() {

	      lowButton.addEventListener(MouseEvent.CLICK, lowClick);

	      mediumButton.addEventListener(MouseEvent.CLICK, mediumClick);

	      highButton.addEventListener(MouseEvent.CLICK, highClick);

	      bestButton.addEventListener(MouseEvent.CLICK, bestClick);

	}

	 

	private function lowClick(event:MouseEvent):void{

	      stage.quality = StageQuality.LOW;

	}

	 

	private function mediumClick(event:MouseEvent):void{

	      stage.quality = StageQuality.MEDIUM;

	}

	 

	private function highClick(event:MouseEvent):void{

	      stage.quality = StageQuality.HIGH;

	}

	 

	private function bestClick(event:MouseEvent):void{

	       stage.quality = StageQuality.BEST;

	}

	 

	}

	 

	}

	 

	
 
Of course remember to set it as the Document class, and give to your buttons the correct instance names.
 

Add comment


Security code
Refresh