Hi folks,
I need to synchronize functionality with various animations... unfortunately jQuery queues up ONLY animations of a certain object.
jQuery offers the possibility to add callbacks, but I cannot pass it any external variables.
Here is some code!!! =)
var unicorn_actions = [...];
for( var i=0; i<unicorn_actions.length; i++){
var unicorn_action = unicorn_actions[i];
if(unicorn_action['type'] == 'movement'){
$('#unicorn').animate({...}, unicorn_action['time']);
}
else if(unicorn_action['type']=='action'){
$('#unicorn').animate({}, 0, function(){
// I NEED TO APPEND THE ACTION TO THE ANIMATION
perform_action(unicorn_action);
});
}
}
1st problem
var unicorn_name = "George";
$(...).animate({'top':100,'left':100 }, 100, function(){
alert(unicorn_name);
})
This returns unicorn_name undefined!
2nd problem
If i need to append a callback to an animation queue I'm thinking of doing the following
$(...).animate({'top':100,'left':100 }, 0, function(){
// my actions
})
This messes up the animations...
Any ideas guys? =)