내용 보기

작성자

관리자 (IP : 172.17.0.1)

날짜

2020-07-09 05:15

제목

[FLEX] Air Application 실행시 풀 스크린모드로 변경하기



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="windowedapplication1_creationCompleteHandler(event)" applicationComplete="windowedapplication1_applicationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;
            
            import spark.components.Application;
            
            protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
            {
                nativeWindow.stage.addEventListener(KeyboardEvent.KEY_DOWN, this.onKeyDown);
            }
            
            protected function windowedapplication1_applicationCompleteHandler(event:FlexEvent):void
            {
                stage.addEventListener(FullScreenEvent.FULL_SCREEN, this.fullScreenHandler);
                
                this.toggleFullScreen();
            }
            
            protected function onKeyDown(event:KeyboardEvent):void
            {
                if (event.keyCode == 27)
                {
                    event.preventDefault();
                }
            }
            
            private function fullScreenHandler(evt:FullScreenEvent):void
            {
                // TODO : ESC키를 눌러 nomal모드로 변경 못하도록 처리
                if(stage.displayState == StageDisplayState.NORMAL)
                    stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
            }
            
            private function toggleFullScreen():void
            {
                try
                {
                    switch (stage.displayState)
                    {
                        case StageDisplayState.FULL_SCREEN:
                            stage.displayState = StageDisplayState.NORMAL;
                            break;
                        default:
                            stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
                            break;
                    }
                }
                catch (err:SecurityError)
                {
                    //
                }
            }
            
            protected function textarea1_keyDownHandler(event:KeyboardEvent):void
            {
                trace(event.keyCode);
            }
            
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Button x="426" y="431" label="Button"/>
    <s:Label x="270" y="202" text="Label"/>
    <s:Label x="570" y="202" text="Label"/>
    <s:TextArea x="362" y="240" width="251" height="80" keyDown="textarea1_keyDownHandler(event)"/>
</s:WindowedApplication>
cs


출처1

출처2