Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flash中一段时间不活动后的navigateToURL_Flash - Fatal编程技术网

Flash中一段时间不活动后的navigateToURL

Flash中一段时间不活动后的navigateToURL,flash,Flash,如果鼠标在三分钟内没有移动,我希望重新启动我的应用程序。我使用“navigateToURL”返回第一个场景,但是如何使用actionscript 3实现这样一个定时事件?非常简单-您需要使用两个事件侦听器: MouseEvent.MOUSE\u移动事件侦听器 TimerEvent.TIMER事件侦听器 您还需要一个计时器对象 这是代码 //private timer var in your class private var myLittleTimer:Timer; /

如果鼠标在三分钟内没有移动,我希望重新启动我的应用程序。我使用“navigateToURL”返回第一个场景,但是如何使用actionscript 3实现这样一个定时事件?

非常简单-您需要使用两个事件侦听器:

  • MouseEvent.MOUSE\u移动事件侦听器
  • TimerEvent.TIMER事件侦听器
  • 您还需要一个计时器对象

    这是代码

        //private timer var in your class
        private var myLittleTimer:Timer;
    
        //This is your main function, where you adding all the event listeners
        //IMPORTANT NOTE:
        //We can only track mouse movement over the flash stage in a DisplayObject that
        //has the link to the main stage
        //For example, your main SPRITE
        yourMainFunction():void{
            //Timer initialization
            this.myLittleTimer = new Timer(3000, 1);
            this.myLittleTimer.addEventListener(TimerEvent.TIMER, lazinessDetector);
            this.myLittleTimer.start();
    
            this.addEventListener(Event.ADDED_TO_STAGE, init);
        }
        private function init(e:Event):void{
            this.removeEventListener(Event.ADDED_TO_STAGE, init);
            //THIS IS THE ENTRANCE POINT
            //do not use stage object before the sprite has been added to the stage
            //as it will cause a null object exception
    
            //We add a MOUSE_MOVE event listener to the stage to track the moment when
            //the mouse has moved
            stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
        }
        private function onMouseMove(e:MouseEvent):void{
            this.myLittleTimer.reset();
            this.myLittleTimer.start();
            //This function will reset the "countdown" timer and start it over again.
        }
        private function lazinessDetector(e:TimerEvent):void {
            //YOUR URL REDIRECT CODE GOES HERE
        }