To see my “updated” code in action:
It works fine if you click slowly and not too fast. BUT if you click way fast it appears the tweens get interrupted and the pictures dont make it all the way to their destinations. Any ideas how I can make it work even for fast user mouse clicks?
Here is the code that handles the tweens on clicks:
// create Fuse objects for custom tweening
var mover:Fuse = new Fuse();
var mover2:Fuse = new Fuse();
var rotate:Fuse = new Fuse();
// function that is called after first initial tween takes place
function firstTweenDone(){
// place top image on level below all other images
stack[0].swapDepths(depth–);
// tween the image back and underneath all other images
mover.pop(); // remove contents from fuse object so next click doesnt get confused
mover.pop();
mover2.pop();
// tween top image back behind rest o fthe images
mover2.push({target:stack[0],x:0,y:0,rotation:stack[0].changerot,ease:“easeOutQuad”,seconds:0.25});
mover2.start();
// tween the 2nd image so its straight and no longer rotated
rotate.pop();
// rotate/tween the image below top image so its not crooked
rotate.push({target:stack[1],rotation:0,ease:“easeOutQuad”,seconds: 0.05});
rotate.start();
// Move top image to the back of the stack array
var addback = stack.shift(); //Removes the first element from an array
stack.push(addback); // put first element at end of array
}
// treat invisible movieclip as a button…do following after each mouseclick
Cover.onRelease = function() {
// Shuffle the current top image to the side and up
stack[0].changerot = (Math.random ()*16)-8-stack[0]._rotation; // calculate random rotation that top image will change to
mover.push({target:stack[0],x:gox,y:goy,rotation:stack[0].changerot,ease:“easeInQuad”,seconds:0.25});
// add function callback to run after tween is done running
mover.push({func:“firstTweenDone”});
mover.start();
};