纳金网
标题:
Delayed Execution (Script Utilities Behavior)
[打印本页]
作者:
Asen
时间:
2011-10-20 15:42
标题:
Delayed Execution (Script Utilities Behavior)
Delayed Execution (Script Utilities Behavior)
Summary
Provides the ability to call a function after a certain delay.
Category
Latest Behaviors
Author
Gavin Kistner
Difficulty
(Reference)
Time to Complete
5 Minutes
Downloads
Click Here
to download the associated files.
(This document covers version 1.0.1 of the 'Delayed Execution' behavior, current as of 2005-Feb-11)
Description
This utility library adds the ability to call a function after a certain number of frames or number of seconds have passed.
The supplied callback function will be***cuted in the scope of whatever object invoked the
frameDelayedExecute(...)
or
timeDelayedExecute(...)
methods. These methods are available on every object, including globally.
To use, include this behavior anywhere in the scene, and then:
frameDelayedExecute( myFunctionName, 30 );
//function will***n in global scope 30 frames from now
this.frameDelayedExecute( myFunctionName, 30 );
//function will***n in the current scope
otherObj.timeDelayedExecute( this.doStuff, 5 );
//My method will***n in the scope of otherObj
//in 5 seconds
You can cancel a delayed callback by storing the return value from
frameDelayedExecute()
or
timeDelayedExecute()
, and then passing that value to
cancelDelayedExecute()
:
this.delayID = this.frameDelayedExecute( 5, closeMenu );
...
if ( userMovedOverMenu )
{
cancelDelayedExecute( delayID );
}
Note that the
cancelDelayedExecute()
method is available only as a global function; each returned
delayID
is unique, and hence cancelling the delayed callback is not dependant upon the object whose scope it is set to***n inside of.
If you change your mind and want the callback to***n immediately instead of later, pass ***e as a second parameter to
cancelDelayedExecute()
:
cancelDelayedExecute( delayID, ***e );
//Invokes the callback immediately,
//and prevents it from being called later
Demonstration
View Demonstration Project
Download Project File
作者:
晃晃
时间:
2012-2-18 23:21
爱咋咋地!
作者:
晃晃
时间:
2012-2-23 23:27
你们都躲开,我来顶
作者:
晃晃
时间:
2012-3-13 23:28
很经典,很实用,学习了!
作者:
晃晃
时间:
2012-3-30 23:31
不错啊 经典
作者:
tc
时间:
2012-4-8 23:31
凡系斑竹滴话要听;凡系朋友滴帖要顶!
作者:
奇
时间:
2012-5-3 23:22
人过留名!
作者:
菜刀吻电线
时间:
2012-7-2 23:24
先垫一块,再说鸟
作者:
tc
时间:
2012-10-29 23:31
先垫一块,再说鸟
作者:
奇
时间:
2012-11-8 23:22
水……生命之源……灌……
作者:
tc
时间:
2012-11-28 23:22
百度的叫度娘,网易的叫易娘,新浪内部还在为是叫新娘还是浪娘而争论不休!……不管你们是企鹅的额娘,豆瓣的伴娘,还是华为的伪娘,都要记得,淘宝才是你们的亲娘啊!亲!!
作者:
tc
时间:
2013-2-8 23:21
谢谢楼主,真是太实用了
作者:
菜刀吻电线
时间:
2013-2-12 23:29
读铁系缘分,顶铁系友情
作者:
C.R.CAN
时间:
2013-2-16 23:29
楼主收集的可真全哦
作者:
奇
时间:
2013-3-8 23:19
我是老实人,我来也!
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5