flex SystemManger監(jiān)控用戶是否和程序打交道
更新時(shí)間:2009年05月25日 18:44:18 作者:
flex中可以通過(guò)SystemManger監(jiān)控用戶是否和程序打交道
例如:
var sysMan:SystemManager = Application.application.systemManager;
sysMan.removeEventListener(FlexEvent.IDLE, timeoutHandler);
// timeout after twenty seconds
public var timeout:Number = 20000;
private var timeoutTotal:Number = 0;
private var timeoutLastCall:Number;
public var sessionExpired:Boolean = false;
public var enableTimeout:Boolean = true;
private function timeoutHandler(event:FlexEvent):void
{
// get current time
var curTime:int = getTimer();
var timeDiff:int = 0;
if (isNaN(timeoutLastCall)) {
timeoutLastCall = curTime;
}
timeDiff = curTime - timeoutLastCall;
timeoutLastCall = curTime;
// if time has passed since the idle event we assume user is interacting
// reset time total - otherwise increment total idle time
if (timeDiff > 1000) {
timeoutTotal = 0;
}
else {
// update time
// the status field will not be updated unless the application is idle
// it is only display a countdown for learning purposes
timeoutTotal += 100;
status.text = "Timeout in " + String(Number((timeout - timeoutTotal)/1000).toFixed(0)) + " seconds";
}
// if the total time of inactivity passes our timeout
// and the session already hasn't expired then logout user
if (timeoutTotal > timeout && !sessionExpired) {
// logout user
// or set flag
sessionExpired = true;
status.text = "timeout threshold has been reached";
//當(dāng)時(shí)間超過(guò)之后執(zhí)行的語(yǔ)句
sessionTimeoutHandler();
}
}
var sysMan:SystemManager = Application.application.systemManager;
sysMan.removeEventListener(FlexEvent.IDLE, timeoutHandler);
// timeout after twenty seconds
public var timeout:Number = 20000;
private var timeoutTotal:Number = 0;
private var timeoutLastCall:Number;
public var sessionExpired:Boolean = false;
public var enableTimeout:Boolean = true;
private function timeoutHandler(event:FlexEvent):void
{
// get current time
var curTime:int = getTimer();
var timeDiff:int = 0;
if (isNaN(timeoutLastCall)) {
timeoutLastCall = curTime;
}
timeDiff = curTime - timeoutLastCall;
timeoutLastCall = curTime;
// if time has passed since the idle event we assume user is interacting
// reset time total - otherwise increment total idle time
if (timeDiff > 1000) {
timeoutTotal = 0;
}
else {
// update time
// the status field will not be updated unless the application is idle
// it is only display a countdown for learning purposes
timeoutTotal += 100;
status.text = "Timeout in " + String(Number((timeout - timeoutTotal)/1000).toFixed(0)) + " seconds";
}
// if the total time of inactivity passes our timeout
// and the session already hasn't expired then logout user
if (timeoutTotal > timeout && !sessionExpired) {
// logout user
// or set flag
sessionExpired = true;
status.text = "timeout threshold has been reached";
//當(dāng)時(shí)間超過(guò)之后執(zhí)行的語(yǔ)句
sessionTimeoutHandler();
}
}
相關(guān)文章
flex 調(diào)試無(wú)法正常啟動(dòng)原因分析及解決方法
在調(diào)試Flex程序的時(shí)候,經(jīng)常后遇到進(jìn)度為57%無(wú)法調(diào)試的情況,本文將介紹詳細(xì)的解決方法,需要的朋友可以參考下2012-12-12
Flex Javascript交互實(shí)現(xiàn)代碼
刪除swf這里需要提醒下,因?yàn)閑mbedSWF是替換標(biāo)簽,而不是填充。2009-06-06
Flex 實(shí)現(xiàn)可以拖動(dòng)的毛玻璃效果
這是一個(gè)使用Flex實(shí)現(xiàn)的可拖動(dòng)的毛玻璃效果(效果在文章后面),具體我就不說(shuō)了,直接帖代碼。2009-11-11
Flex 創(chuàng)建一個(gè)自定義風(fēng)格的HRule或VRule
Flex中如何通過(guò)strokeWidth, strokeColor和shadowColor樣式,創(chuàng)建一個(gè)自定義風(fēng)格的HRule或VRule2009-06-06
Flex 處理服務(wù)器端傳來(lái)的數(shù)據(jù)
對(duì)于Java端返回的各種Java類型的對(duì)象,F(xiàn)lex中能否有相應(yīng)的數(shù)據(jù)類型來(lái)映射。這是Flex與服務(wù)器通信使用remoteObject的關(guān)鍵。2009-08-08

