PDA

View Full Version : Anyone got a better code???



jbrereton3
September 28th, 2003, 06:04 AM
Hi, I pretty much want the timeline to stop until the Space Bar has been touched and obviously, continue on when it has been touched...

the code I've tryed to use is here:

if (Key.onPress(Key.SPACE)) {
gotoAndPlay(2);
} else {
stop();
}

all I really want is if someone has a better code that acctually does the job

Thanks,
jbrereton3

kode
September 28th, 2003, 01:13 PM
this.onKeyDown = function() {
if (Key.isDown(Key.SPACE)) {
this.gotoAndPlay(2);
}
};
this.stop();
Key.addListener(this);

jbrereton3
September 30th, 2003, 01:19 AM
thanks heaps!!!

kode
September 30th, 2003, 02:00 AM
Welcome. ;)

jbrereton3
October 8th, 2003, 08:52 AM
Hey, you woulden't happen to know how I could use that same code but have two varibles...

I've tryed:

this.onKeyDown = function() {
if (Key.isDown(Key.LEFT)) {
this.gotoAndPlay(2);
}
};
this.stop();
Key.addListener(this);
this.onKeyDown = function() {
if (Key.isDown(Key.RIGHT)) {
this.gotoAndPlay(57);
}
};
this.stop();
Key.addListener(this);

Any suggestions???

kode
October 8th, 2003, 09:01 AM
It doesn't work as you expected because you're overwriting the onKeyDown handler!! :P

this.onKeyDown = function() {
if (Key.isDown(Key.LEFT)) this.gotoAndPlay(2);
else if (Key.isDown(Key.RIGHT)) this.gotoAndPlay(57);
};
this.stop();
Key.addListener(this);

jbrereton3
October 8th, 2003, 09:53 AM
Thanks very much

kode
October 8th, 2003, 09:54 AM
Welcome (again). :beam: