본문 바로가기
디자인

플래시 FullScreen(풀스크린) - AS3.0, AS2.0

by 세이박스 2008. 10. 27.
반응형
 
 
 
본 코드는 Flash Player9 이상에서 작동하며 Html단의 object태그에 다음 붉은 글씨가 추가로 삽입된다.
--------------------------------------------------------------------------------------------
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,18,0"
width="600"  height="400" id="fullscreen" align="middle">
<param name="allowFullScreen" value="true" />
<param name="movie" value="fullscreen.swf" />
<param name="bgcolor" value="#333333" />
<embed src="fullscreen.swf" allowFullScreen="true" bgcolor="#333333" width="600" height="400"
name="fullscreen" align="middle" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
-----------------------------------------------------------------------
 
다음의 예제 코드는 플래시영역에서 마우스 오른쪽 버튼을 눌렀을경우 풀스크린 메뉴를 추가. 기능을작동시키는
펑션으로 구성되어 있다.
 
 
AS3.0에서 중요한 문장
------------------------------------------------------------------------
//풀창
stage.displayState = StageDisplayState.FULL_SCREEN;
//노멀창
stage.displayState = StageDisplayState.NORMAL;
----------------------------------------------------------------
 
 
 
AS2.0에서 중요한 문장
------------------------------------------------------------------------
//풀창
Stage["displayState"] = "fullScreen";
//노멀창
Stage["displayState"] = "normal";
----------------------------------------------------------------
 
 
 
AS3.0 형식
/*********************************************************************************/
import flash.display.Stage;
import flash.display.StageDisplayState;
import flash.display.InteractiveObject.*;
import flash.events.*;

// functions to enter and leave full screen mode
function goFullScreen(event:ContextMenuEvent):void
{
   stage.displayState = StageDisplayState.FULL_SCREEN;
}
function exitFullScreen(event:ContextMenuEvent):void
{
   stage.displayState = StageDisplayState.NORMAL;
}

// function to enable and disable the context menu items,
// based on what mode we are in.
function menuHandler(event:ContextMenuEvent):void
{
   if (stage.displayState == StageDisplayState.NORMAL)
   {
      event.target.customItems[0].enabled = true;
      event.target.customItems[1].enabled = false;
   }
   else
   {
      event.target.customItems[0].enabled = false;
      event.target.customItems[1].enabled = true;
   }
}

// create the context menu, remove the built-in items,
// and add our custom items
var fullscreenCM:ContextMenu = new ContextMenu();
fullscreenCM.addEventListener(ContextMenuEvent.MENU_SELECT, menuHandler);
fullscreenCM.hideBuiltInItems();

var fs:ContextMenuItem = new ContextMenuItem("Go Full Screen" );
fs.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, goFullScreen);
fullscreenCM.customItems.push( fs );

var xfs:ContextMenuItem = new ContextMenuItem("Exit Full Screen");
xfs.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, exitFullScreen);
fullscreenCM.customItems.push( xfs );

// finally, attach the context menu to a movieclip
mc.contextMenu = fullscreenCM;
 
------------------------------------------------------------------------------------------------/
 
 
 
AS2.0 형식
/*********************************************************************************/
// functions to enter and leave full screen mode 
function goFullScreen() { 
	Stage["displayState"] = "fullScreen"; 
} 
function exitFullScreen() { 
	Stage["displayState"] = "normal"; 
} 
// function to enable, disable context menu items, based on which mode we are in. 
function menuHandler(obj, menuObj) { 
	if (Stage["displayState"] == "normal") { 
	// if we're in normal mode, enable the 'go full screen' item, 	disable the 'exit' item 
		menuObj.customItems[0].enabled = true; 
		menuObj.customItems[1].enabled = false; 
	} else { 
	// if we're in full screen mode, disable the 'go full screen' item, enable the 'exit' item 
		menuObj.customItems[0].enabled = false; 
		menuObj.customItems[1].enabled = true; 
	} 
} 
// create a new context menu 
var fullscreenCM:ContextMenu = new ContextMenu(menuHandler); 
// hide the regular built-in items 
fullscreenCM.hideBuiltInItems(); 
// now, add the items to enter and leave full screen mode 
var fs:ContextMenuItem = new ContextMenuItem("Go Full Screen", goFullScreen); 
fullscreenCM.customItems.push( fs ); 
var xfs:ContextMenuItem = new ContextMenuItem("Exit Full Screen", exitFullScreen); 
fullscreenCM.customItems.push( xfs ); 
// now, attach the context menu to any movieclip in your movie. 
// here we attach it to _root, (even though using _root is generally a bad idea,) 
// so it will appear if you right click anywhere on the movie. 
_root.menu = fullscreenCM;
----------------------------------------------------------------------------------------- 
반응형