『我闪网~www.5shan.com』

Categories

-=推荐开发方面的Flash新闻、教程、下载、酷站、游戏、图片等=-
首页

Links

New Comments

Counter

Calendar

[教程]函数定时执行

Author:我闪 PublishTime:2004-10-1

Dimitrios扩展了的Function类,版本AS1,代码如下:
// Function callAfter
// by Dimitrios Bendilas (d.bendilas@zefxis.gr)
Function.prototype.callAfter = function(_lag:Number, _parameters:Array) {
   var sTime = getTimer();
   var _function = this;
   var timer = setInterval(function () {
      if (getTimer()-sTime>=_lag) {
          _function.apply(null, _parameters);
          clearInterval(timer);
      }
   }, 50, this);
};
用法:
function traceData(name:String, age:Number) {
   trace(name+", age "+age);
}
traceData.callAfter(2000, ["John", 25]);// 2000 milliseconds

(出自Jiagao

分类于:我闪推荐

Comments

{CommentAuthor} at {CommentTime} | {CommentEmail} {CommentUrl} {CommentIp}
{CommentContent}
Powered by 5DBlog.com