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

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

Flex程序开发心得小结

和Flash的开发环境相比,Flex提供的组件库确实很诱人,但由于功能太全面,导致程序的体积大,有时候使用不当,可能会影响程序运行效率。
收藏 0 赞 0 分享

关于FLASH与XML交互应用中的理解

关于XML在FLASH中的应用,以前写过几篇。也收集了几篇来自网络的。不过,都是一些非常简单而常用的。在这里,我把XML的其他相关说明总结一下。有不足之处,希望大家能相互补充。只为了一个共同的目的:共同提高。
收藏 0 赞 0 分享

Flash Event写法

flash下event事件驱动方法
收藏 0 赞 0 分享

AS3自写类整理笔记 ClassLoader类第1/2页

在用flash做项目的时候,把一些元件,通过设置链接类,然后使用这个类,通过getClass方法即可把这个素材拿下来
收藏 0 赞 0 分享

AS3自写类整理笔记:ByteLoader类

该类的主要功能是把swf,jpg,png,gif等文件以字节的形式加载进来 以便于使用Loader.loadBytes方法,重复加载使用素材 如果图片格式为jpg,并且是渐进式格式jpeg,那么该类还可以帮助你边加载边显示
收藏 0 赞 0 分享

AS3自写类整理笔记 Dot类第1/2页

拖拽物体1和物体2,就可以看到效果了 index.base.geom.Dot类讲解 基本功能:记录xy两点
收藏 0 赞 0 分享

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 分享
查看更多