PDA

View Full Version : animator .addAsyncCall problem



victor
10 Nov 2006, 10:07 PM
Hi,

I am having problem understanding the animator.addAsyncCall.

Animation doesn't go beyond the asyncall. The animations in asyncCall_1 work fine, but the other animations beyond it don't. If I remove it then everything works.
What is the meaning of the callbackIndex which you give in your example as 1.

I have this as a test async function


function asyncCall(){
showin_s.dom.innerHTML += "
Async Call"
setTimeout(asyncCall_1,1000);
}

function asyncCall_1(){
//document.getElementById("showin").innerHTML += "
Async Call"
showin_s.dom.innerHTML += "
Async Call _ 1"
showin_s.highlight("#ffffcc",null,3);
showin_s.play();

}


and in the animator the following




// start capturing
animator.startCapture();
xclickme.highlight("#ffffcc",null,2);
xclickme.highlight("#ffffff",null,2);
// these animations will be run in sequence
cursor.show();
cursor.moveTo(500,400);

//cursor.moveTo(20, getEl('navbar').getY()+10, true, .75);
cursor.moveTo(getEl(clickon).getX(), getEl(clickon).getY(), true, .75);
click.show();
click.alignTo(cursor, 'tl', [-4, -4]);
animator.pause(.5);



//*******
animator.addAsyncCall(asyncCall, 1);





// Add an async function call, pass callback to argument 1

//animator.addCall(asyncCall);
//animator.addAsyncCall(asyncCall, 1);

animator.addCall(aCall);
// pause .5 seconds
animator.pause(.5);

// again, these animations will be run in sequence
click.hide(true, .7);
cursor.alignTo('splitter', 'tr', [0, +100], true, 1);
resize.alignTo('splitter', 'tr', [-12, +100]);

// start sync block: these animations will run at the same time
animator.beginSync();
cursor.hide();
resize.show();
animator.endSync();

// play the captured animation sequences, call myCallback when done
animator.play(myCallback);

jack.slocum
10 Nov 2006, 10:23 PM
For async calls you need to provide a callback parameter index (and your async function has to actually make the callback).

So if you had:


function asyncFn(foo, bar, callback){
setTimeout(function(){
callback();
}, 250);
}
....
animator.addAsyncCall(asyncFn, 2);

Then the callback index would be 2. All async operations generally have a method for making a callback. Without a callback there's no way to know when it has completed.

Make sense?

victor
10 Nov 2006, 10:52 PM
It worked. thanks for the quick reply.
How can we engage you for 1 to 1 session? Issue wise or Hourly?

jack.slocum
10 Nov 2006, 11:31 PM
Either. Send me an email and I'd be happy to discuss it.

victor
10 Nov 2006, 11:44 PM
Is it possible to do this ?

call addAsyncCall(aFn,1)

where the aFn() makes a call to update manager to update a div(which is an actor)
with some content and then after that animate that actor?

your typical 10 lines would be great help, if this is possible

jack.slocum
11 Nov 2006, 12:43 AM
The update manager has a callback parameter.


function updateEl(cb){
getEl('foo').load('bar.php', 'param1=wtf', cb);
}
animator.addAsyncCall(updateEl, 0);

jack.slocum
11 Nov 2006, 12:44 AM
load() is new in the latest build and is a shortcut for getUpdateManager().update(...)

victor
12 Nov 2006, 9:23 PM
Can we send scope & params to the callback function??

jack.slocum
13 Nov 2006, 4:54 AM
Take a look at the docs and you tell me. :)