手机
当前位置:查字典教程网 >网页设计 >Flash教程 >flex SystemManger监控用户是否和程序打交道
flex SystemManger监控用户是否和程序打交道
摘要:例如:varsysMan:SystemManager=Application.application.systemManager;sysMa...

例如:

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 SystemManger监控用户是否和程序打交道】相关文章:

flash教程:使用拆分数字和文字的函数

FLASH制作跳动的小球

mc深度的排序值设置方法

Flash制作旋转拖尾文字效果

FLASH鼠标点击显示打散动画

Flash AS解决中文mp3乱码

Flash8滤镜与混合模式:近距离预览滤镜效果

Flash制作卡通风格的石头和山脉实例教程

Flash制作中常用的脚本

flash基础之图层状态的运用

精品推荐
分类导航