flex 全屏代码
1 <?xml version="1.0" encoding="utf-8"?>
2 <!-- http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/ -->
3 <mx:Application name="FullScreen_test"
4 xmlns:mx="http://www.adobe.com/2006/mxml"
5 layout="vertical"
6 applicationComplete="init(event)">
7
8 <mx:Script>
9 <![CDATA[
10 import flash.display.StageDisplayState;
11
12 private function init(evt:Event):void {
13 /* Set up full screen handler. */
14 Application.application.stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenHandler);
15 dispState = Application.application.stage.displayState;
16 }
17
18 private function fullScreenHandler(evt:FullScreenEvent):void {
19 dispState = Application.application.stage.displayState + " (fullScreen=" + evt.fullScreen.toString() + ")";
20 if (evt.fullScreen) {
21 /* Do something specific here if we switched to full screen mode. */
22 } else {
23 /* Do something specific here if we switched to normal mode. */
24 }
25 }
26
27 private function toggleFullScreen():void {
28 try {
29 switch (Application.application.stage.displayState) {
30 case StageDisplayState.FULL_SCREEN:
31 /* If already in full screen mode, switch to normal mode. */
32 Application.application.stage.displayState = StageDisplayState.NORMAL;
33 break;
34 default:
35 /* If not in full screen mode, switch to full screen mode. */
36 Application.application.stage.displayState = StageDisplayState.FULL_SCREEN;
37 break;
38 }
39 } catch (err:SecurityError) {
40 // ignore
41 }
42 }
43 ]]>
44 </mx:Script>
45
46 <mx:String id="dispState" />
47
48 <mx:Label text="width={Application.application.width}" />
49 <mx:Label text="height={Application.application.height}" />
50 <mx:Label text="displayState={dispState}" />
51
52 <mx:Button label="Toggle fullscreen" click="toggleFullScreen()" />
53
54 </mx:Application>
2 <!-- http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/ -->
3 <mx:Application name="FullScreen_test"
4 xmlns:mx="http://www.adobe.com/2006/mxml"
5 layout="vertical"
6 applicationComplete="init(event)">
7
8 <mx:Script>
9 <![CDATA[
10 import flash.display.StageDisplayState;
11
12 private function init(evt:Event):void {
13 /* Set up full screen handler. */
14 Application.application.stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenHandler);
15 dispState = Application.application.stage.displayState;
16 }
17
18 private function fullScreenHandler(evt:FullScreenEvent):void {
19 dispState = Application.application.stage.displayState + " (fullScreen=" + evt.fullScreen.toString() + ")";
20 if (evt.fullScreen) {
21 /* Do something specific here if we switched to full screen mode. */
22 } else {
23 /* Do something specific here if we switched to normal mode. */
24 }
25 }
26
27 private function toggleFullScreen():void {
28 try {
29 switch (Application.application.stage.displayState) {
30 case StageDisplayState.FULL_SCREEN:
31 /* If already in full screen mode, switch to normal mode. */
32 Application.application.stage.displayState = StageDisplayState.NORMAL;
33 break;
34 default:
35 /* If not in full screen mode, switch to full screen mode. */
36 Application.application.stage.displayState = StageDisplayState.FULL_SCREEN;
37 break;
38 }
39 } catch (err:SecurityError) {
40 // ignore
41 }
42 }
43 ]]>
44 </mx:Script>
45
46 <mx:String id="dispState" />
47
48 <mx:Label text="width={Application.application.width}" />
49 <mx:Label text="height={Application.application.height}" />
50 <mx:Label text="displayState={dispState}" />
51
52 <mx:Button label="Toggle fullscreen" click="toggleFullScreen()" />
53
54 </mx:Application>