Simple Full Screen Mode
March 14th, 2009 Posted in ActionScript 3.0
A friend of mine had a problem with a Full Screen Mode, and for resolve the issue he asked me, how to make a Full Screen Mode with two buttons, The first for Full Screen Mode and the second for Normal Screen, yesterday I make this project. She’s a verry simple work, even if you are new in ActionScript, you will undersund this code. This Full Screen Mode can be make in AIR. Well, this is the code:
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | package { // ---------------------------------------- // Imports // ---------------------------------------- import flash.display.MovieClip; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.display.StageDisplayState; import flash.events.MouseEvent; import flash.text.TextField; import flash.events.Event; public class FullScreen extends MovieClip { // ---------------------------------------- // Variables // ---------------------------------------- //Same public variables which will help us in the following private methodes // That will be the Full Screen button public var fullScreen_mc:MovieClip = new MovieClip(); // And this will be the button that will stop the Full Screen Mode public var stopFullScreen_mc:MovieClip = new MovieClip(); //The text that will be displayed in the top left on the stage public var textLabel:TextField = new TextField(); //The text that will be displayed when your mouse will be on top off a button public var toolTip:TextField = new TextField(); public function FullScreen():void { // ---------------------------------------- // CONSTRUCTOR // --------------------------------------- //Now set the constructor of your ActionScript class //Set the stage position stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; stage.addEventListener(Event.ENTER_FRAME, checkStatus); drawButton(fullScreen_mc); drawButton(stopFullScreen_mc); writeText(textLabel); writeText(toolTip); //Make the toolTip invisible, because we whant to be visible wehen will be on top off a button toolTip.visible = false; fullScreen_mc.x = 0; stopFullScreen_mc.y = fullScreen_mc.width + 10; textLabel.y = 0; //The events that will be applyed to this button with(fullScreen_mc) { addEventListener(MouseEvent.CLICK, putFullScreen); addEventListener(MouseEvent.ROLL_OVER ,rollOverMe); addEventListener(MouseEvent.ROLL_OUT, rollOutMe); } //same here...the events that will be applyed to this button with(stopFullScreen_mc) { addEventListener(MouseEvent.CLICK, stopFullScreen); addEventListener(MouseEvent.ROLL_OVER, rollOverMe); addEventListener(MouseEvent.ROLL_OUT, rollOutMe); } } // ---------------------------------------- // Public Methods // ---------------------------------------- public function rollOverMe(event:MouseEvent):void { toolTip.visible = true; switch(event.currentTarget) { case stopFullScreen_mc: toolTip.htmlText = "<b>End Full Screen Mode</b>"; break; case fullScreen_mc: toolTip.htmlText = "<b>Full Screen Mode</b>"; break; } } public function rollOutMe(event:MouseEvent):void { toolTip.text = ""; toolTip.visible = false; } public function drawButton(obj:MovieClip):void { with(obj.graphics) { beginFill(0x666666, 1); drawRect(0,50,120,30); endFill(); } addChild(obj); obj.buttonMode = true; } public function writeText(obj:TextField):void { obj.autoSize = "left"; obj.border = true; obj.background = true; obj.backgroundColor = 0XFFFFFF; addChild(obj); } public function putFullScreen(event:MouseEvent):void { stage.displayState = StageDisplayState.FULL_SCREEN; textLabel.htmlText = "The application is in <b>Full Screen Mode</b>. Press the other button or press <b>ESC</b> button to escape"; } public function stopFullScreen(event:MouseEvent):void { stage.displayState = StageDisplayState.NORMAL; textLabel.text = ""; } public function checkStatus(event:Event):void { if(stage.displayState == StageDisplayState.NORMAL) { textLabel.htmlText = "The application is in <b>Normal Screen Mode</b>. Press the first button for Full Screen Mode"; } toolTip.x = mouseX + 20; toolTip.y = mouseY + 20; } } } |
And the final result you can download from here :Full Screen Mode

July 23rd, 2009 at 2:33 AM
tks for the effort you put in here I appreciate it!