var h:Home = new Home();
q1 = EventQueue.registerQueue("queue1");
q1.addImmediateEvent(h, h.doCircle);
q1.addEvent(h, h.goDown);
q1.addEvent(h, h.doSomething);
q2 = EventQueue.registerQueue("queue2");
q2.addEvent(h, h.goAcross);
q2.addEvent(h, h.doFade,[30]);
q2.addEvent(h, h.goDown,[],"unpaused"); // wait for an "unpaused" event before continuing (see Home::unpause)
q2.addEvent(h, h.doFade, [100])
q2.addEvent(h, h.goAcross);
q1.addEvent(q2, q2.start);
q1.addEvent(h, h.doFade,[30])
q1.addEvent(h, h.doSomething);
q1.addEvent(h, h.doSomething);
q1.start();
Class EventQueue
{
var _qID;
function addEvent(scope,fn,args,bContinue)
{
e={scope:scope, fn:fn, args:args, bContinue:bContinue};
_queue.push(e);
}
function processEvent()
{
e=_queue.shift();
fn=e.fn'
...
blah blah..
...
_eventManager.addEventListener("complete", _eventListener);
_eventManager.addEventListener("qcomplete", _eventListener);
fn._qID = _qID; // ***********************************
fn.apply(scope, args); // ***********************************
}
}
Class Home
{
..
..
public function makeQueueDelegate(fn,qID)
{
var fdel:Function = Delegate.create(this, fn);
fdel._qID = qID;
return(fdel);
}
public function goDown()
{
var _qID = arguments.callee._qID; // *********************************** callee is the fn.apply in the queue class
_tweens[Home._mc.square_mc] = Home._mc.square_mc;
Home._mc.square_mc.tween("_y", Home._mc.square_mc._y + 100, 1, "linear", 0, makeQueueDelegate(goDown_CallBack, _qID));
}
public function goDown_CallBack()
{
// we're going to broadcast the queue id back, for the queue to check whether it sourced this event in the first place
var _qID = arguments.caller._qID; // *********************************** caller is the delegate function from goDown
delete(_tweens[Home._mc.square_mc]);
EventManager.getInstance().dispatchEvent({ target:this, type:"complete", _qID:_qID});
}
}