FLEX全屏展示
FLEX全屏显示
全屏显示,第一种写法: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <fx:Style> @namespace s "library://ns.adobe.com/flex/spark"; @namespace mx "library://ns.adobe.com/flex/mx"; global{ font-size:19; } </fx:Style> <fx:Script> <![CDATA[ import mx.controls.Alert; private function fullScr():void{ stage.displayState=StageDisplayState.FULL_SCREEN; //controlScr.label="普通"; //controlScr.addEventListener(MouseEvent.CLICK, normalScr); var contextMenu:ContextMenu=new ContextMenu(); contextMenu.hideBuiltInItems(); var item:ContextMenuItem=new ContextMenuItem("ydq"); item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,alertMsg); contextMenu.customItems.push(item); this.contextMenu=contextMenu; } private function alertMsg(event:ContextMenuEvent):void{ Alert.show("hacker.Ye"); } private function normalScr():void{ //controlScr.removeEventListener(MouseEvent.CLICK,fullScr); stage.displayState=StageDisplayState.NORMAL; } ]]> </fx:Script> <mx:Button label="全屏" click="fullScr();"/> <mx:Button label="普通" click="normalScr()" x="86" y="0"/> <mx:Image source="../WebContent/image/fullscreen.jpg" mouseDown="fullScr();" x="0" y="47" height="25"/> <mx:Image source="../WebContent/image/nofull.jpg" mouseDown="normalScr()" x="96" y="47"/> </s:Application>
全屏显示,第二种写法: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="init()"> <s:layout> <s:BasicLayout/> </s:layout> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <fx:Script> <![CDATA[ import mx.events.FlexEvent; protected function init():void{ this.stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenChange); } private function toggleFullScreen():void{ if(stage.displayState==StageDisplayState.NORMAL){ stage.displayState=StageDisplayState.FULL_SCREEN; }else{ stage.displayState=StageDisplayState.NORMAL; } } protected function fullScreenChange(event:FullScreenEvent):void{ if( this.stage.displayState == StageDisplayState.FULL_SCREEN ){ full.source="/FlexFullScreen/image/nofull.jpg"; full.toolTip="普通显示"; } else{ full.source="/FlexFullScreen/image/fullscreen.jpg"; full.toolTip="全屏显示"; } } ]]> </fx:Script> <!--全屏图标--> <mx:Image id="full" source="/FlexFullScreen/image/fullscreen.jpg" mouseDown="toggleFullScreen()" top="2" left="2" buttonMode="true" toolTip="全屏显示"/> </s:Application>