Thursday, April 7, 2011

Working with windows in AIR: Part 12

In this tutorial we will learn how to enable fullscreen mode in our AIR application.

To do that, you simply need to set the displayState property of the stage object to StageDisplayState.FULL_SCREEN. Let's add a text field and see what happens. Note, that if you don't have any programmed ways to close the window - you'll have to close it using your OS close hotkeys (ALT+F4 for Windows).

import flash.text.TextField;
import flash.display.StageDisplayState;

var myText:TextField = new TextField();
myText.text = "Hello fullscreen world!";
addChild(myText);

stage.displayState = StageDisplayState.FULL_SCREEN;

You can see that the text has been resized. We can make the content non-scalable by setting the stage's scaleMode to StageScaleMode.NO_SCALE.

stage.scaleMode = StageScaleMode.NO_SCALE;

If you test the code now - you'll see that the text is in the middle of the screen. This is because we haven't aligned it. We can fix this by manually setting the alignment:

stage.align = StageAlign.TOP_LEFT;

Here's the full code:

import flash.text.TextField;
import flash.display.StageDisplayState;
import flash.display.StageScaleMode;
import flash.display.StageAlign;

var myText:TextField = new TextField();
myText.text = "Hello fullscreen world!";
addChild(myText);

stage.displayState = StageDisplayState.FULL_SCREEN;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

Thanks for reading!

Related:

Working with windows in AIR: Part 1
Working with windows in AIR: Part 2
Working with windows in AIR: Part 3
Working with windows in AIR: Part 4
Working with windows in AIR: Part 5
Working with windows in AIR: Part 6
Working with windows in AIR: Part 7
Working with windows in AIR: Part 8
Working with windows in AIR: Part 9
Working with windows in AIR: Part 10
Working with windows in AIR: Part 11

2 comments:

Jens Eckervogt said...

Hello nice tutorial! But you forget about example DragDemo like ToolBar from myapp to real utility window like you know example small window like new, open, save, ... to drag to real window and move to other area of myapp.

Dud you know that? But I have problem because NativeDrag and NativeDrop because I am using Flex sdk 4.14.x dragdemo source is very old and outdated. How do we fix it and test drag and drop native with native window to myapp and seperated windows like chrome has seperated tab with window. But I am trying it doesn't show into native window. codingangry.com/demo/dragDemo <- Here example of drag and drop native "custom drag" method do you find it. Thanks!

Jens Eckervogt said...

Sorry "d" is wrong. full address of tutorial: http://codingangry.com/index.php/site/article/drag_drop_windows/
Thanks sorry for double post...

Post a Comment