var def = {
when: function(func) {
func(function(data) {
if (typeof def.handler == 'function') def.handler(data);
});
return this;
},
then: function(func) {
def.handler = func;
}
};
function move(figure){
figure.x += 10;
if (figure.x < 200) setTimeout(move, 25);
}