FULL_SCREEN_INTERACTIVE mode: the “Allow” button click is passed to the application

后端 未结 2 402
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-06 06:54

In an AS3 game (using Flex 4.10.0) I would like to allow players to chat, even when they are in fullscreen mode.

So I am using the following ActionScript code (the <

2条回答
  •  生来不讨喜
    2021-01-06 07:41

    As you mentioned, you need to create transparent layer to avoid undesired click events. you can hide this layer when screen returned to normal state or user accepted fullscreen state (FULL_SCREEN_INTERACTIVE_ACCEPTED event will fired).

    Demo (flashplayer 11.3 required)

    var transparentLayer:Sprite=new Sprite();
    var timer:Timer = new Timer(50, 1);
    init();
    function init():void {
        transparentLayer.graphics.beginFill(0,0.1);
        transparentLayer.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
        transparentLayer.graphics.endFill();
        transparentLayer.visible=false;
        addChild(transparentLayer);
        timer.addEventListener(TimerEvent.TIMER_COMPLETE,handleTimerComplete);
        stage.addEventListener(FullScreenEvent.FULL_SCREEN_INTERACTIVE_ACCEPTED,handleFSIA);
        _fullBox.addEventListener(MouseEvent.CLICK,toggleFullScreen);
        stage.addEventListener(FullScreenEvent.FULL_SCREEN, handleFullScreen);
    }
    function toggleFullScreen(e:MouseEvent):void {
        if(stage.displayState == StageDisplayState.NORMAL){
            stage.displayState=StageDisplayState.FULL_SCREEN_INTERACTIVE;
    
            transparentLayer.visible=ExternalInterface.available;
    
        }else
            stage.displayState=StageDisplayState.NORMAL;
    }
    function handleFullScreen(e:FullScreenEvent):void {
        _fullBox.selected = e.fullScreen;
        if(stage.displayState == StageDisplayState.NORMAL)
            transparentLayer.visible=false;
    }
    function handleFSIA(e:FullScreenEvent):void{
        timer.reset();
        timer.start();
    }
    function handleTimerComplete(e:TimerEvent):void{
        transparentLayer.visible=false;
    }
    

提交回复
热议问题