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

所属分类: 网页制作 / Flash 阅读数: 1293
收藏 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();
}
}
更多精彩内容其他人还在看

js与flash的交互FLASH连播控制器

js与flash的交互FLASH连播控制器
收藏 0 赞 0 分享

Flash CS3组件开发图文教程

Flash CS3组件开发图文教程
收藏 0 赞 0 分享

flash as Actionscript中的数组的使用方法

flash as Actionscript中的数组的使用方法
收藏 0 赞 0 分享

用flash as脚本 控制 Flash中文本框样式的代码

用flash as脚本 控制 Flash中文本框样式的代码
收藏 0 赞 0 分享

209个透明flash背景以及使用方法详解

我们平时做站的时候偶尔会用到一些比较炫的透明flash去修饰页面,但如果你自己并没有那么高深的flash技术可以随意创造心中所想的效果时,那么这些flash透明和背景或许能帮到你,其中有一些是很漂亮的!
收藏 0 赞 0 分享

比较漂亮的几款可爱的flash日历收藏

比较漂亮的几款可爱的flash日历收藏
收藏 0 赞 0 分享

Flash 与 html 的一些实用技巧

Flash 与 html 的一些实用技巧
收藏 0 赞 0 分享

全flash站制作剖析

全flash站制作剖析
收藏 0 赞 0 分享

flash加载各种外部文件

flash加载各种外部文件
收藏 0 赞 0 分享

收藏了98个flash片头

收藏了98个flash片头
收藏 0 赞 0 分享
查看更多