flex SystemManger监控用户是否和程序打交道

所属分类: 网页制作 / Flash 阅读数: 1318
收藏 0 赞 0 分享
例如:
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";
//当时间超过之后执行的语句
sessionTimeoutHandler();
}
}
更多精彩内容其他人还在看

了解在Flash中的编程工作第1/4页

了解在Flash中的编程工作
收藏 0 赞 0 分享

FLV视频上传到网上不能播放的原因与解决办法

FLV视频上传到网上不能播放的原因与解决办法
收藏 0 赞 0 分享

Flash与后台数据交换方法整理

Flash与后台数据交换方法整理
收藏 0 赞 0 分享

FLASH基础开发习惯第1/2页

FLASH基础开发习惯
收藏 0 赞 0 分享

网页中嵌入Flash的方法讨论

网页中嵌入Flash的方法讨论
收藏 0 赞 0 分享

flash组件开发要点第1/2页

flash组件开发要点
收藏 0 赞 0 分享

修改flash之必备软件硕思闪客精灵3.3注册破解版下载

硕思闪客精灵 MX 是一款用于浏览和解析Flash动画(.swf文件和.exe文件)的工具
收藏 0 赞 0 分享

使用 AllowNetworking Flash的世界安静了

使用 AllowNetworking Flash的世界安静了
收藏 0 赞 0 分享

FCS中ActionScript代码提示功能

FCS中ActionScript代码提示功能
收藏 0 赞 0 分享

Flash ActionScript 中按钮和电影剪辑的事件和方法

Flash ActionScript 中按钮和电影剪辑的事件和方法
收藏 0 赞 0 分享
查看更多