PDA

View Full Version : Failed Delay / How do you Create a Delay?



iamapathy
April 27th, 2003, 01:59 AM
I read through the AS dictionary, and searched the forums :P but still I can't figure out how to create a delay, for my movie. I just want the scripted animation to pause for 4 seconds before resuming. I have this code on a movie clip.


onClipEvent (load) {
_root.loading = "up";
_root.done = true;
function switchVar() {
if (_root.done == true) {
_root.done = false;
}
}
}
onClipEvent (enterFrame) {
if (_root.done == false) {
if (_root.loading == 'down') {
MovementLeft = _y-397;
_y = Math.ceil(_y-MovementLeft/2);
if (MovementLeft == 1) {
_root.loading = "up";
_root.done = true;
}
} else if (_root.loading == 'up') {
MovementLeft = 410-_y;
_y = Math.floor(MovementLeft/2+_y);
if (MovementLeft == 1) {
_root.loading = "down";
_root.done = true;
}
}
} else if (_root.done == true) {
setInterval(switchVar(), 4000);
}
}


Help?

iamapathy
April 27th, 2003, 02:26 AM
Nevermind.... I figured it out. I just rearranged my code to look like this...

onClipEvent (load) {
//since the MC is already up set the variable to up
_root.loading = "up";
//every 1500 milliseconds
setInterval(function () {
// if it's up, change it to down
if (_root.loading == 'up') {
_root.loading = "down";
//if it's down change it to up
} else {
_root.loading = "up";
}
}, 1500);
}
onClipEvent (enterFrame) {
if (_root.loading == 'down') {
MovementLeft = _y-397;
_y = Math.ceil(_y-MovementLeft/2);
} else if (_root.loading == 'up') {
MovementLeft = 410-_y;
_y = Math.floor(MovementLeft/2+_y);
}
}