If password = ... goto frame ... need scripting help!

Hello! I have a page that uses an altered version of kirupas if/else password tutorial, to make my website skip to a frame according to which password the user types in. I have used this code:

password = inputName

/////// PRIVATE GALLERIES 1-5

if (password == “aurore1”) {
gotoAndStop (“g1”);
_root.containerp.loadMovie (“site/g1.swf”);
}
if (password == “barbara2”) {
gotoAndStop (“g1”);
_root.containerp.loadMovie (“site/g2.swf”);
}
if (password == “catherine3”) {
gotoAndStop (“g1”);
_root.containerp.loadMovie (“site/g3.swf”);
}
if (password == “diana4”) {
gotoAndStop (“g1”);
_root.containerp.loadMovie (“site/g4.swf”);
}
if (password == “eleanor5”) {
gotoAndStop (“g1”);
_root.containerp.loadMovie (“site/g5.swf”);
}

(I have 10 more if these if statements)
The swf loads ok, but I get the error:

256 levels of recursion were exceeded in one action list.
This is probably an infinite loop.
Further execution of actions has been disabled in this movie.

I guess there is a much better way to store these passwords so this error doesnt occur!
Can anyone please help me modify that??

Heres hoping!
Natalie

there is a thing called case switch statement… search/google/destroy

The recursion is probably occurring somewhere else in the code rather than within your if statements. After all, Flash will just evaluate each of your passwords in turn…if none of them match, Flash will ignore any code within the brackets and no recusion occurs. Likewise, should one of your if statements evaluate as true, Flash will run the code within the brackets.

A case switch statement will do the same thing, it just makes it easier to manage a lot of if statements. But if there’s a problem elsewhere in your code, it won’t prevent you from getting that error message.

So first thing is to check your code for any loops. Another thing to try is to remove the _root references because the actual _root will change to that of the loaded movieclip - so it might be a case that Flash is trying to load g1.swf into _root.containerp…but then containerp no longer exists as it’s been replaced by g1.swf…so Flash tries to load g1.swf into _root.g1.swf…and so on. In other words, using _root might inadvertently cause Flash to enter into a constant loop while it tries to load the g1.swf movie into itself.

Wow! Thanks for the replies! I will take away the _root references and see if that fixes it :smiley: