簡易コマンド実行関数

January 30, 2009category: Flash 

簡易コマンド実行関数を書いた。理由は Tweener でシーケンシャルな処理をしたかったら。単純に動けばいいだけなので、AS2で。

private function executeFunctions():Function {
  var thisObject:Object = arguments[0];
  var root:Function = arguments.callee;
  return (function():Function {
    var executed:Function = arguments.callee;
    for (var i:Number = 1; i < arguments.length; i++) (function(current:Function, next:Function) {
      current.done = function():Void {
        next ? next.call(thisObject, next) : executed.onComplete();
      };
    }).call(thisObject, arguments[i], arguments[i + 1]);
    arguments[1].call(thisObject, arguments[1]);
  return arguments.callee;
  }).apply(root, arguments);
}

usage

executeFunctions(this,
  (function(self) {
    Tweener.addTween(hoge, {_x: 100, time: 1, onComplete: function():Void {
      self.done();
    }});
  }),
  (function(self) {
    Tweener.addTween(hoge, {_x: -100, time: 1, onComplete: function():Void {
      self.done();
    }});
  }),
  (function(self) {
    Tweener.addTween(hoge, {_x: 0, time: 1, onComplete: function():Void {
      self.done();
    }});
  })
).onComplete = function():Void {
  trace("done"); 
};

comments (0)このエントリーを含むはてなブックマークはてなブックマーク - 簡易コマンド実行関数

comments