Connecting Tech Pros Worldwide Forums | Help | Site Map

[CS3](AS2) How to make entire movieclip play using 'key.isDown'

Newbie
 
Join Date: Jan 2009
Posts: 1
#1: Jan 29 '09
This is a script for a character that walks in 4 directions. That works fine. I have also added other random movieclip animations for other keystrokes.

I want a movie clip to play through when a key is pressed. Right now the movieclip only plays while the key is being held. How do I get it to continue to play even if the key is released? I am not sure if I need to add something to my action script or change it entirely.

Here is my script:

onClipEvent(load) {
speed = 5;
grow = 3;

}
onClipEvent(enterFrame){
if(Key.isDown(49)){
this.gotoAndStop("right");
this._x+=speed;


}else if(Key.isDown(50)){
this.gotoAndStop("left");
this._x-=speed;

}else if(Key.isDown(51)){
this.gotoAndStop("back");
this._xscale -= this.grow;
this._yscale -= this.grow;

}else if(Key.isDown(52)){
this.gotoAndStop("front");
this._xscale += this.grow;
this._yscale += this.grow;

}else if(Key.isDown(53)){
this.gotoAndStop("crazy");

}else if(Key.isDown(54)){
this.gotoAndStop("snowball");



}else{
this.gotoAndStop("stand")
}
}

Any suggestions would be appreciated!

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#2: Feb 14 '09

re: [CS3](AS2) How to make entire movieclip play using 'key.isDown'


how about, gotoAndPlay() ?
Reply

Tags
actionscript, animation, character, key.isdown, movieclip