all groups > flash (macromedia) > august 2007 >
You're in the

flash (macromedia)

group:

how to add delay to keylistener


how to add delay to keylistener ominah
8/22/2007 10:50:14 PM
flash (macromedia):
I have 3 mcs on the stage that i want to move into position in order on a
keypress, but after each moves into position, I want a slight delay so it
doesn't switch too fast. Is is possible to put a delay in after the mc is in
place - maybe with a setInterval or something?

stop();
duplicateMovieClip("baby0", "newbaby_mc", this.getNextHighestDepth());
newbaby_mc._x = 300;
newbaby_mc._y = 237;

var Step:Number = 1;

Key.addListener(this);

this.onKeyUp = function(){
var Baby:String = "baby"+Step;

if (Step <= 3){

removeMovieClip(newbaby_mc);
duplicateMovieClip(Baby, "newbaby_mc", this.getNextHighestDepth());
newbaby_mc._x = 300;
newbaby_mc._y = 237;
Step++;
trace("Step through");
}
else {
trace("back to beginning");
removeMovieClip(newbaby_mc);
duplicateMovieClip("baby0", "newbaby_mc", this.getNextHighestDepth());
newbaby_mc._x = 300;
newbaby_mc._y = 237;
Step = 1;
}

}



Re: how to add delay to keylistener dzedward
8/23/2007 2:17:42 AM
:

stop();
duplicateMovieClip("baby0", "newbaby_mc", this.getNextHighestDepth());
newbaby_mc._x = 300;
newbaby_mc._y = 237;

var Step:Number = 1;

Key.addListener(this);

this.onKeyUp = function() {
var Baby:String = "baby"+Step;

if (Step<=3) {

removeMovieClip(newbaby_mc);
duplicateMovieClip(Baby, "newbaby_mc", this.getNextHighestDepth());
newbaby_mc._x = 300;
newbaby_mc._y = 237;
wait = setInterval(waitForIt, 500);// 500=half second
function waitForIt() {
Step++;
trace("Step through");
}
} else {
trace("back to beginning");
removeMovieClip(newbaby_mc);
duplicateMovieClip("baby0", "newbaby_mc", this.getNextHighestDepth());
newbaby_mc._x = 300;
newbaby_mc._y = 237;
Step = 1;
}

};
Re: how to add delay to keylistener edmundep2
8/23/2007 4:38:27 AM
AddThis Social Bookmark Button