PDA

View Full Version : Passwords for Levels (plural)


guitarhero
12-22-2008, 09:10 PM
Hi

I'd like to have codes for each level, so you can jump directly to that level from a enter-code-frame. Like here (http://amanita-design.net/samorost-2/), for example.

So far, i've tried the following:
password = inputName; [with a form with that variable]
plus
on (release) { if (password == "1234") {gotoAndPlay(4);} }

Any help is appreciated!

Bunney lord
12-23-2008, 04:47 AM
Try:

stop();
var myContextMenu:ContextMenu = new ContextMenu();
this.myContextMenu.hideBuiltInItems();
this.menu = myContextMenu;
this.goBtn.onRelease = function() {
if (isNaN(_root.levelTxt.text)) {
_root.gotoAndStop(_root.levelTxt.text);
}
}


The code first hides the context menu so the player can't go control the game by right clicking. Then, when the button is released, it checks to see if the the value in not a number, then it goes to the frame labeled whatever the value is. So all you need to do is make an input text-field and name it 'levelTxt' and make a button names 'goBtn'. Then for each level, label it's frame the password you want.