Created
April 7, 2009 14:31
-
-
Save oleganza/91255 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pierlis.framework | |
{ | |
import flash.events.* | |
import fl.transitions.* | |
import pierlis.framework.* | |
/* | |
var tq = new TweenQueue() | |
tq.push(function(){ new Tween(...) }) | |
tq.push(function(){ new Tween(...) }) | |
tw.addEventListener(TweenEvent.MOTION_FINISH, myCallback) | |
*/ | |
public class TweenQueue extends EventDispatcher | |
{ | |
public var push:Function | |
public function TweenQueue(eventType = null) | |
{ | |
this.eventType = (eventType || TweenEvent.MOTION_FINISH) | |
push = firstPush | |
} | |
private var eventType | |
private var currentTween | |
private var queuedFun | |
private function firstPush(fun) | |
{ | |
currentTween = fun(this) | |
currentTween.addEventListener(eventType, onQueueFinish) | |
push = secondPush | |
} | |
private function secondPush(fun) | |
{ | |
queuedFun = fun | |
currentTween.removeEventListener(eventType, onQueueFinish) | |
currentTween.addEventListener(eventType, onIntermediateFinish) | |
push = thirdPush | |
} | |
private function thirdPush(fun) | |
{ | |
queuedFun = fun | |
} | |
private function onQueueFinish(e) | |
{ | |
push = firstPush | |
dispatchEvent(e) | |
} | |
private function onIntermediateFinish(e) | |
{ | |
currentTween = queuedFun() | |
currentTween.addEventListener(eventType, onQueueFinish) | |
push = secondPush | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment