i need to make an animation frame by frame, basically after pressing the mouse the animation starts by changing background image like some kind of stop motion by using this code:
document.addEventListener('click', function() {
if(counter<1){
audioElement.play();
var cancello=document.getElementById("cancello1");
//var cancello2=document.getElementById("cancello2");
TweenMax.to(cancello, 3, {rotationY:125, transformOrigin:"left top",opacity:0})
TweenMax.to(cancello2, 3, {opacity:0})
contatore++;
}
else if(counter<2){
TweenLite.set($("#porta"), {css:{backgroundImage:'url(img/KDS_Grafiche29.png)'}}); <--this one
audioElement.setAttribute('src', '235.wav');
audioElement.play();
//var porta = document.getElementById("porta");
//TweenLite.to(porta,5,{opacity:1,scaleX:2,scaleY:2});
contatore++;
}
else if(counter<3){
TweenLite.set($("#porta"), {css:{backgroundImage:'url(img/KDS_Grafiche212.png)'}}); <-- second frame
var titolo = document.getElementById("titolo");
TweenLite.to(titolo,2,{opacity:1});
contatore++;
}
else if (counter<4){
TweenLite.set($("#porta"), {css:{backgroundImage:'url(img/KDS_Grafiche220.png)'}}); <-- third frame
} }
the problem is that the image flash for second before appearing, also... how can i impost an automatic cycle in which the images appear one by one, since the actual cycle only increases at every click. or there's a better way to do this without using tweenlite.set()?