一个时间问题
是这样的,有关一个时间问题,大家帮忙分析下
需求是这样的:
针对一个DataGird中的每行数据,在每一次查询后,和上次数据进行对比,若存在新数据在指定时间内后(如2分钟后)进行提醒,但是在这2分钟内,无论在查询多少次,只提醒这一次,等待提醒结束后,在循环上述过程,但若查询后无新数据,则更新提醒时间
[解决办法]
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="init(event)" xmlns:s="library://ns.adobe.com/flex/spark"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.controls.Text; import mx.managers.PopUpManager; private var alert:Alert; import flashx.textLayout.factory.StringTextLineFactory; import mx.events.FlexEvent; import org.osmf.events.TimeEvent; [Bindable] public var str:String; public var timer:Timer; private function showA(delay:Number):void { timer = new Timer(1000); timer.start(); var alertTitle:String = "提示:"; alert = Alert.show("正在执行A方法", alertTitle); setTimeout(hideAlertA, delay*1000); } private function showB(delay:Number):void { timer = new Timer(1000); timer.start(); var alertTitle:String = "提示:"; alert = Alert.show("正在执行B方法", alertTitle); setTimeout(hideAlertB, delay*1000); } private function hideAlertA():void { //b(); PopUpManager.removePopUp(alert); } private function hideAlertB():void { a(); PopUpManager.removePopUp(alert); } protected function init(event:FlexEvent):void { // TODO Auto-generated method stub timer = new Timer(1000); timer.addEventListener(TimerEvent.TIMER,timehandle); timer.start(); } private function timehandle(e:TimerEvent):void { var count:int = timer.currentCount; str = timeTransform(3,count); } private function timeTransform(stattime:int,counter:int):String { var str:String = ""; var count:int = stattime - counter; var second:int = count%60; str = second+"秒"; return str; } private function a():void{ timer = new Timer(1000); var t:int = timer.currentCount; //xxxxxxxA方法内容 showA(5-t); } private function b():void{ timer = new Timer(1000); //xxxxB方法内容 var t:int = timer.currentCount; showB(5-t); } private function run():void{ for(var i:int=0;i<100;i++){ if(i%10==0){ if(i%5==0&&i%10!=0){ a(); }else{ b(); } } } } ]]> </mx:Script> <mx:ApplicationControlBar dock="true"> <mx:Button label="test" click="run();" /> </mx:ApplicationControlBar> </mx:Application>