Full Screen mode – AS3 Flash Player 9

29 01 2008

[UPDATED] sample site that I used the fullscreen mode: http://my-magic-circle.com.

[UPDATED] sample code added. See below.

Just came across the full-screen issue in AS3. It turned out to be pretty easy to deal with. I am stoked Flash Player 9 has this feature. Developers need to do both of the following 2 things to make this happen.

[Step One] Actionscript

package{

	import flash.display.StageDisplayState;
	import flash.display.Sprite;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;

	public class Main extends Sprite{
		public var _fullScreen_btn:MovieClip;

		protected function handleMouseUp(me:MouseEvent):void
		{
			if (stage.displayState == StageDisplayState.NORMAL) {
				try{
					stage.displayState=StageDisplayState.FULL_SCREEN;
				}
				catch (e:SecurityError){
					//if you don't complete STEP TWO below, you will get this SecurityError
					trace("an error has occured. please modify the html file to allow fullscreen mode")
				}
			}
		}
		public function Main(){
			_fullScreen_btn.addEventListener(MouseEvent.MOUSE_UP,handleMouseUp,false,0,true);
		}
	}
}

[Step Two] html script (the code which embeds the .swf file in the page)

In short, you need to update the value of the param “allowFullScreen” to be “true”.

If the html script was published by Flash IDE, you need to
update two instances of “allowFullScreen” , both from “false” to “true”.

If the html script was published by Flex IDE, you need to add the param
“allowFullScreen” with the value “true” at four places.

My references:

http://www.adobe.com/devnet/flashplayer/articles/full_screen_mode.html
http://www.flashxpress.net/forum/showthread.php?t=64585

Thanks to my friend Will Carpenter’s help.


Actions

Information

5 responses

24 08 2008
asdasd

stupid, put some code

28 11 2008
paulo

thx!

22 05 2009
nauris

Is there a way to show only one movie clip in full screen instead of all stage?

28 05 2009
Hu

@nauris. You can define a Rectangle as the boundary of the scale. Refer to the 2nd reference link I posted. Code snippet looks like:
var scalingRect:Rectangle = new Rectangle(video.x, video.y, video.width, video.height);
stage["fullScreenSourceRect"] = scalingRect;

21 06 2009
KIAMOZ

gratE ;) .

Leave a comment