Well, I tried to make a code so that when the main character hittests the talking character that the talking character would go to a random frame to display a random message. The problem was that when the space bar is down, it will continuously go to random frames without stopping... What I'm really trying to accomplish here, is to make it so that when the space bar is held down It goes to and stops on a random frame of the talking character, and when the space bar is released the talking character returns to frame one (Which is the idle stance).
Sorry for the mouthful, I don't want to confuse anyone. Thanks a bunch
PHP Code:
onClipEvent(enterFrame) {
if (this.hitTest(_root.char) && Key.isDown(Key.SPACE)) {
_root.talkingchar.gotoAndStop(random(4)+2);
}
else if (!(Key.isDown(Key.SPACE))) {
_root.talkingchar.gotoAndStop(1);
}
}
Where do I place this code? When I replaced the second line of code with your code it did not work. Is there something else I must input to make the code function? I'm kind of new to action script 2.0 and I'm not to familiar with Boolean functions. Can you help out a bit more? Thanks
He he, I really don't understand how the code works, but it functioned flawlessly, thanks a bunch! And I will go back to the forums to try to help others out.
It's checking to see if the character is on frame 1 before changing the frame, and then changes the frame randomly, and so it is no longer on frame 1, and doesn't enter the statement again.