Help for "if" Actionscript

Please help… I’m rookie in Actionscripts
I’m trying to make appears an “arrow” movie clip called “freccia” only if/when the user enters the username in a textfield imput box.
I’ve entered the followng script in the keyframe:

if (username == null) {
setProperty(“freccia”, _alpha, “0”);
} else if (username == true) {
setProperty(“freccia”, _alpha, “100”);

but there’s something missing because at start the arrow is not shown (because of the alpha “0”) but then when I enter some text in the imput field the arrow is not appearing…

You ActionScript masters…Can you help to identify what’s wrong here… Thank you so much

being the actionscript newbie that i am this is only a guess but i think you need to supply an action for neither of those requirements being met. because you have and if statement and an else if … both of which are requirements that are possible … even simultaneously possible, but you have not specified what flash should do if none are true.

what do you think pom?

hope this helps

Not sure… which other instruction I need to add. The first part of the instruction is true when the movie starts (no text has been entered yet)… but it’s when I entered some text in the imput field… I think I need to find a way to tell flash “re-check again if the condition is true…”

Thank you

Put the script on an empty movie clip and edit the code a little bit like this:

onClipEvent(enterFrame) {
    if (_root.username == null) {
        setProperty("_root.freccia", _alpha, "0");
    } else if (username == true) {
        setProperty("_root.freccia", _alpha, "100");

Yep. The problem is that you test it only once. So at first it’s false, the arrow isn’t visible. That’s why you have to include your test in a handler (onClipEvent (enterFrame)) so that Flash can test the textbox once more.

And Shuga, if flash doesn’t find any if that works, it just does… nothing :slight_smile:

pom :asian:

Thank you very much guys for the hints
I tried your solution and now all works OK.


so could i use a conditional statement with a text input box like that to make a rudimentary password protection?

where the user will have to enter a password to get to the next frame of the movie


You can…but passwords in Flash are never 100% secure, thats why you want it to be more dynamic then to just go to the next frame…any user can get to your next frame if he knows aything about the flash player!