[MX] Disable an input text box

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 :wink:


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:

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!

Thanks, Ill try that out later… but yeah should work.

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

I have never used this one and dont know how it works but you may want to try!


you can set a textfield’s type to “input” (editable) or “dynamic” (not editable).

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


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.


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 ? :slight_smile:


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 :slight_smile:

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.

“myTextField” was just an arbitrary label for an imaginary textfield, you should replace that with the correct path.instanceName of your textfield.