Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Disable/enable a input textfield

Explorer ,
Jun 23, 2011 Jun 23, 2011

Dear all,

How do I disable and enable an input textfield?

I have tried these but it returns me with error

1119: Access of possibly undefined property editable through a reference with static type flash.text:TextField.

mc_box.txt_input.editable = false;

mc_box.txt_input.enabled = false;

I have the input textfield inside a movieclip.

I have already imported:

import flash.text.TextField;

TOPICS
ActionScript
9.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , Jun 23, 2011 Jun 23, 2011

You can't able to use the enabled property for textbox, another workaround is here:

mc_box.txt_input.type=TextFieldType.DYNAMIC; //to disable the textbox

mc_box.txt_input.type=TextFieldType.INPUT; //to enable the textbox

at runtime

Translate
Mentor ,
Jun 23, 2011 Jun 23, 2011

You can't able to use the enabled property for textbox, another workaround is here:

mc_box.txt_input.type=TextFieldType.DYNAMIC; //to disable the textbox

mc_box.txt_input.type=TextFieldType.INPUT; //to enable the textbox

at runtime

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 23, 2011 Jun 23, 2011

Thanks, relaxatraja

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 23, 2011 Jun 23, 2011

You'r Welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 24, 2013 Jul 24, 2013
Main.as 1120: Access of undefined property TextFieldType.

I'm trying to make a button toggle this activity.

My code:

btnCapture.addEventListener(MouseEvent.MOUSE_OVER, DisableText);

function DisableText(event:MouseEvent):void

{

sample.textbox1.type=TextFieldType.DYNAMIC; //to disable the textbox

sample.textbox2.type=TextFieldType.DYNAMIC; //to disable the textbox

}

btnCapture.addEventListener(MouseEvent.MOUSE_OUT, EnableText);

function EnableText(event:MouseEvent):void

{

sample.textbox1.type=TextFieldType.INPUT; //to enable the textbox

sample.textbox2.type=TextFieldType.INPUT; //to enable the textbox

}

Any idea why this shouldn't work? Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 24, 2013 Jul 24, 2013

you might need to import that class:

import flash.text.TextFieldType

if that triggers an error message, your publish settings are incorrect.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 24, 2013 Jul 24, 2013

Try importing the TextFieldType class ( import flash.text.TextFieldType; ). 

Running a shortened version of that code in the timeline with objects to match I do not get that error and the code appears to work as planned.  Since the error you show indicates a Main.as class file might be involved that might be the difference... class files need to import anything they use.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 24, 2013 Jul 24, 2013

Thanks guys, I wonder why the error reporting doesn't suggest that, how does anyone know what needs to be imported, and how many things are available to import?

How would anyone even know that importing something you've never heard of is the solution?

Thanks again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 24, 2013 Jul 24, 2013
LATEST

All good questions Jefferey... it becomes mostly a matter of intuition after you have banged your head against enough walls over time... you should talk to the guys there and see what they can do to alleviate things like this.

I particularly like errors where you are cryptically told there is a problem with loading a file, but no indication of the file name is given... which has to be known by the software and would help solve the issue almost immediately in most cases.

You should also start your own postings instead of piggy backing on someone else's, especially one that has been marked as answered... Not only do you have that working against you, but your name is shared by one of the employees that manages another forum and I ignored it for quite a while figuring it was just being moved from one forum to another by that person.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines