Checking value of input text?

Hi folks,

Working on a simple dog and pony show that needs to fake some password entry. I’m in Flash CS3 using AS2.0.

I have an Input Text field named “txt_pinnums” and its line type is set to Password. It has a variable of “pinpassword”.

All I want to do when “btn_ok” is pressed is check that the numbers entered on the keypad that are now in the input text field equal “1234”. It seems though that the value of that field is a bunch of HTML, not simple characters. Here is what I have:


stop();
txt_pinnums.text = "";

function checkPin() {
    if(pinpassword eq "1234") {
        trace("good");
    }
    else
    {
        trace("bad");
    }
}


btn_ok.onRelease = function() {
    checkPin();
}

I’m sure my AS is not that good, but as I said this is just a simple show and tell demo that will be thrown away. How can I test that the input text equals 1234? If I do a trace(pinpassword) I get a bunch of HTML in addition to the characters entered.

Also, one syntactical question. I tried this:


btn_ok.onRelease = checkPin;

But that doesn’t work… that type of thing works in JS though. Curious as to why it doesn’t work.


stop();
txt_pinnums.text = "";

function checkPin() {
    if(txt_pinnums.text == "1234") {
        trace("good");
    }
    else
    {
        trace("bad");
    }
}


btn_ok.onRelease = function() {
    checkPin();
}  

is that what you are talking about?

[quote=mrwicked;2337382] ActionScript Code:
[LEFT][COLOR=#0000FF]stop[/COLOR]COLOR=#000000[/COLOR];
txt_pinnums.[COLOR=#0000FF]text[/COLOR] = [COLOR=#FF0000]""[/COLOR];

[COLOR=#000000]function[/COLOR] checkPinCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR][COLOR=#000000]([/COLOR]txt_pinnums.[COLOR=#0000FF]text[/COLOR] == [COLOR=#FF0000]“1234”[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]trace[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#0000FF]else[/COLOR]
[COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]trace[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

btn_ok.[COLOR=#0000FF]onRelease[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
checkPinCOLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]

is that what you are talking about?[/quote]

For my second question, in a sense yes - I’m just wondering why you can’t assign a function call directly to an event. I guess AS doesn’t work that way. It’s no big deal was just curious, it works the way I have it. I more needing to get my main problem solved of checking the “password”.

what I wrote is checking the password. Its checking if the password input is 1234 and if it is, trace good else trace bad

Whoops! Somehow I missed that, I see it now. Thanks! I will try that.