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

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

AS3 中的package(包)应用实例代码

初学者在学习AS3时会遇到什么样的问题呢?只有从初学的角度来实践,才能知道,package 这个高手们必玩的内容,对初学者来说或许就有一些困惑。
收藏 0 赞 0 分享

swfupload使用代码说明

终于在天哪joyous的帮助下,花了一天的时间,搞明白大部分内容. swfupload(以下简称su)遇到的主要问题就是,版本不同造成的极大差异, 现在的版本已经到2.1beta。我用的是2.02版,天哪用的是1.xx版。
收藏 0 赞 0 分享

Flex中最好的MVC框架Mate框架

个人感觉Mate框架非常适合开发一般运用程序,可以提高开发效率,节约成本,同时也比较好维护。但如果要做游戏或是其它控制更强的程序并不适合。
收藏 0 赞 0 分享

Flex 创建复数行文本内容的List

效果不错的flex多行文本
收藏 0 赞 0 分享

flash/flex/air的一个大问题

Close Advertisement 对HTML标签的支持得不够好。现在普遍的做法是浮一个iframe。
收藏 0 赞 0 分享

flex编程动态生成图像

程序需求:动态生成柱形图,柱形条数不确定,柱形字段不确定
收藏 0 赞 0 分享

帮助你学习 Flash / ActionScript的12个网站

Adobe Flash是一个很好的技术,该技术允许开发人员加入的互动性和平稳的动画网页。 其受欢迎程度是如此巨大,您可以看到许多网站,致力于帮助开发者有兴趣在闪光。
收藏 0 赞 0 分享

入门简单的FLEX验证码一例

入门简单的FLEX验证码一例
收藏 0 赞 0 分享

ActionScript3禁止构造请求标头Referer

ActionScript3禁止构造请求标头Referer
收藏 0 赞 0 分享

做了一个flash视频墙[附源文件与xml文件]

这篇文章主要介绍了做了一个flash视频墙[附源文件与xml文件]
收藏 0 赞 0 分享
查看更多