FMX - Problems with KeyPress for hidden areas

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

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.

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;
}

you’re quite the celeb today Random Hero :slight_smile: and getting in a lot before I do :wink:

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

Just hanging around for the most part, trying to figure out how to do that variable mess. :wink:

http://www.flashkit.com/search.php?cat=movies&field=Description&per=10&page=1&term=password

Thanks Random and Senocular, I have worked out a solution using onClipEvent(keydown) and an if statement.

Cheers.