1

我有一个计时器正在运行,它每秒检查系统日期/时间,并更新应用程序上显示的日期。

如果我更改系统时间,应用程序会在下一秒更新。如果我更改系统时区,则应用程序仅在当前分钟更改时注册此更改。

我有一个小示例应用程序,显示发生的问题(如果您想亲自查看)

在我调用localDate:Date = new Date()的地方,localDate.timezoneOffset直到当前分钟发生变化才反映当前系统时区。但是,如果我更改系统秒数,它们会在下一个计时器滴答声中更新

<?xml version="1.0" encoding="utf-8"?>

        protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
        {
            myTimer = new Timer(1000, 0);
            myTimer.addEventListener(TimerEvent.TIMER, timerHandler, false, 0, true);
            myTimer.start();
        }

        private function timerHandler( event:TimerEvent):void{
            var localTime:Date = new Date();
            offsetLabel.text = localTime.timezoneOffset.toString();
            secondsLabel.text = localTime.seconds.toString();
        }

    ]]>
</mx:Script>
<mx:Label id="offsetLabel" x="33" y="24" width="223" height="58" fontSize="15"/>
<mx:Label id="secondsLabel" x="33" y="90" width="223" height="58" fontSize="15"/>

4

0 回答 0