Wednesday, June 23, 2010

How to switch to fullscreen mode in AS3

Following is the code for the Flash -

import flash.display.StageDisplayState;
function goFullScreen():void {
if (stage.displayState == StageDisplayState.NORMAL) {
} else {
stage.addEventListener(MouseEvent.CLICK, _handleClick);
function _handleClick(event:MouseEvent):void {

Function _handleClick will be called as soon user clicks on the stage which will execute the function goFullScreen which will set the displayState to full screen.

This will only work once you have embedded the flash in HTML and view it in the browser. Another important thing to keep in mind is to set allowFullScreen paramter in the embedding code to true.

In the flash embedding code you will need to have the following -

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=",0,0,0" width="550" height="400" id="test" align="middle">

<param name="allowScriptAccess" value="sameDomain" />

<param name="allowFullScreen" value="true" />
<param name="movie" value="test.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />

<embed src="test.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="test" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="" />


No comments: