PDA

View Full Version : [MX] Disable an input text box



GregD
October 30th, 2002, 10:40 AM
Hey Guys,

Just a quick question... I currently have a button which checks to see if the values of text boxes are correct before displaying a tick or a cross to indicate this.

I want to disable the input text boxes so no data can be written into them once they are correct...

So my code so far within the button:

on (release) {
if (input1 == "140" && input2 == "180" && input3 == "140" && input4 == "180" && input5 == "640") { //if these values are entered in the input boxes <input1> etc.
setProperty(_root.ticka, _visible, true); //tick becomes visible
//code needs to go here for disabling input txt boxes
} else {
setProperty(_root.crossa, _visible, true); // cross becomes visible
}
}


I read up on some sites dedicated to flash/actionscripting but the closest i could find was this for an input text field:

yourTextField.onChanged = function() {
yourTextField.selectable = false;
};

I needed it within the if statement, so i couldnt figure out how it worked.

If anyone can help me on this ill be grateful ;)

Thanks

pom
October 30th, 2002, 10:47 AM
Well, I don't have Flash on that computer, but your best bet is to check the textfield methods in the AS Dictionary. Everything's there. And if it is not there, it doesn't exist.

pom :cowboy:

srinivas
October 30th, 2002, 11:24 AM
What I usually do is have a mc with 0 alpha away from the stage and then setProperty to move it on to the text field. Make sure that the mc is on top of the text field. This way it blocks the input field and you cannot enter text once u have the correct answer. Hope this helps!

GregD
October 30th, 2002, 11:29 AM
Thanks, Ill try that out later... but yeah should work.

I was just wondering if there was a disabled/enabled option.

srinivas
October 30th, 2002, 11:32 AM
I have never used this one and dont know how it works but you may want to try!

TextField._visible

sbeener
October 30th, 2002, 07:41 PM
you can set a textfield's type to "input" (editable) or "dynamic" (not editable).

myTextField.type = "dynamic" // to disable, "input" to enable

GregD
October 31st, 2002, 04:29 AM
Srinivas:

Your movie clip method doesnt work too well because you can still enter text into the input box... unless im doing something wrong, its on the layer above the textbox and i brought it to the front but it still lets me do things to the text box.

sbeener:

Ive used it like this

setProperty(_root.ticka, _visible, true);
myTextField.type = "dynamic";

I tried using instance variable names where it says myTextField and label names (where it says var in properties) and I cant seem to get it working...

I've tried setting a variable also

myTextField = input1.text;

This doesnt give me much joy either... I must be doing something wrong but I don't understand what. Can anyone shed some light on this ? :)

GregD
October 31st, 2002, 04:57 AM
Srinivas:

Got it now thanks man... i converted some Dynamic text to a movie clip and stuck it in front/made it become visible once someone got it right...

Thanks everyone for your help :)

srinivas
October 31st, 2002, 10:27 AM
Sorry it was my mistake! I forgot to mention that the mc should have a rectangular or square box and then make the mc alpha as 0. The you will block it totally and you can not enter any text into the input box. If its an empty mc with alpha 0 this doesnt work.

sbeener
October 31st, 2002, 01:21 PM
"myTextField" was just an arbitrary label for an imaginary textfield, you should replace that with the correct path.instanceName of your textfield.