Skip to content

Instantly share code, notes, and snippets.

@oleganza
Created April 7, 2009 14:31
Show Gist options
  • Save oleganza/91255 to your computer and use it in GitHub Desktop.
Save oleganza/91255 to your computer and use it in GitHub Desktop.
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