PDA

View Full Version : FMX - Problems with KeyPress for hidden areas



topsocket
February 20th, 2003, 08:25 AM
Hello, I'm trying to set up a secret area within a site that is accessed by typing in a string of characters i.e password

I can do this no problems using the KeyPress function moving one frame forward within a separate movie each time the expected character is pressed until the full string has been entered and the movie jumps to the secret area.

The problem is that when using this method the string can be entered with many other characters pressed in between the expected ones. I need the ability to reset the password movie when an unexpected key is pressed.

If this makes any sense whatsoever and anyone can help me out I would be very gratefull.

Cheers.

Topsocket

Random Hero
February 20th, 2003, 08:34 AM
sounds like you need an if -> else statement in there, otherwise, I'd pick up one of those password gateway examples...saw a few on flashkit.com. good luck.

senocular
February 20th, 2003, 08:35 AM
try something like this



pass = "password"
position = 0;
Key.addListener(this);
this.onKeyDown = function(){
if (Key.getAscii() == pass.charCodeAt(position)){
if (++position >= pass.length) _root.gotoAndPlay("secretframe");
}else position = 0;
}

senocular
February 20th, 2003, 08:35 AM
you're quite the celeb today Random Hero :) and getting in a lot before I do ;)

topsocket
February 20th, 2003, 09:45 AM
Thanks for that senocular, I included this code within an onClipEvent (keyDown) for the movie but still nothing happens. Is the postition variable meant to incriment within the first if statement?

Cheers

Topsocket

Random Hero
February 20th, 2003, 09:51 AM
Just hanging around for the most part, trying to figure out how to do that variable mess. ;)

Random Hero
February 20th, 2003, 09:55 AM
http://www.flashkit.com/search.php?cat=movies&field=Description&per=10&page=1&term=password

topsocket
February 20th, 2003, 10:44 AM
Thanks Random and Senocular, I have worked out a solution using onClipEvent(keydown) and an if statement.

Cheers.