Posted By

adrianparr on 09/21/10


Tagged

display screen fullscreen full as3 quit fscommand trapallkeys displayState scaleMode


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

Demian
bobbym245
tspitzr
albertomori


AS3 Fullscreen Projector Demo with Escape Key to Quit (with confirmation screen)


 / Published in: ActionScript 3
 

URL: http://www.adrianparr.com/flash/fullscreen_demo/FullscreenDemo.zip

This is designed to be used with a Flash Projector (not in the browser or AIR) and only displays your movie in fullscreen mode. Download source files from here ... http://www.adrianparr.com/flash/fullscreen_demo/FullscreenDemo.zip

  1. package
  2. {
  3. import flash.display.Sprite;
  4. import flash.display.StageDisplayState;
  5. import flash.display.StageScaleMode;
  6. import flash.events.KeyboardEvent;
  7. import flash.events.MouseEvent;
  8. import flash.ui.Keyboard;
  9. import flash.system.fscommand;
  10.  
  11. public class FullscreenDemo extends Sprite
  12. {
  13.  
  14. public function FullscreenDemo():void
  15. {
  16. fscommand("trapallkeys", "true");
  17.  
  18. stage.showDefaultContextMenu = false;
  19. stage.displayState = StageDisplayState.FULL_SCREEN;
  20. stage.scaleMode = StageScaleMode.SHOW_ALL;
  21. stage.addEventListener(KeyboardEvent.KEY_DOWN, onStage_KEY_DOWN);
  22.  
  23. quitScreen_mc.visible = false;
  24. quitScreen_mc.yesBtn_mc.addEventListener(MouseEvent.CLICK, onQuitYes_CLICK);
  25. quitScreen_mc.noBtn_mc.addEventListener(MouseEvent.CLICK, onQuitNo_CLICK);
  26. quitScreen_mc.yesBtn_mc.buttonMode = true;
  27. quitScreen_mc.noBtn_mc.buttonMode = true;
  28. }
  29.  
  30. function onStage_KEY_DOWN(evt:KeyboardEvent):void {
  31. if (evt.keyCode == Keyboard.ESCAPE) {
  32. quitScreen_mc.visible = true;
  33. }
  34. }
  35.  
  36. function onQuitYes_CLICK(evt:MouseEvent):void {
  37. fscommand("quit");
  38. }
  39.  
  40. function onQuitNo_CLICK(evt:MouseEvent):void {
  41. quitScreen_mc.visible = false;
  42. }
  43.  
  44. }
  45. }

Report this snippet  

You need to login to post a comment.