A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Locking an input text box

  1. #1
    Junior Member
    Join Date
    Jan 2007
    Posts
    5

    Locking an input text box

    How can you make an input text box read-only once someone has typed something into it? (i.e. they are unable to change the contents)

    textboxName.type = "dynamic"; or textboxName.selectable = false; dont seem to work in the following button code ("entry" is the variable name of the input text box):

    on (release)
    {
    if ((entry == "F") | (entry == "f"))
    {
    entry.type = "dynamic";
    correctletters ++;

    if (correctletters == 2)
    {
    completedmessage = "CONGRATULATIONS!";
    }
    }

    else
    {
    entry = "";
    errormessage = "Sorry wrong letter, try again!";
    timer = setInterval(wait, 3000);
    }
    }

    on (keyPress "<Enter>")
    {
    if ((entry == "F") | (entry == "f"))
    {
    entry.type = "dynamic";
    correctletters ++;

    if (correctletters == 2)
    {
    completedmessage = "CONGRATULATIONS!";
    }
    }

    else
    {
    entry = "";
    errormessage = "Sorry wrong letter, try again!";
    timer = setInterval(wait, 3000);
    }
    }

    What else can I do?

  2. #2
    Senior Member
    Join Date
    Jul 2001
    Location
    Planet Earth
    Posts
    298
    Read this a few days ago, and just came across a potential solution.

    After the text is typed in, set the maxChars for that textbox to whatever the length of it is when the button is pressed:
    Code:
    // assumption: The rest of the script is correct
    on (release){
       if ((entry.text == "F") || (entry.text == "f")){
           entry.maxChars = entry.length;
           correctletters ++;
    
           if (correctletters == 2){
                  completedmessage = "CONGRATULATIONS!";
           }
    }
    Hope that helps.
    ---
    Thinking outside of the box will get you fired if the "box" is strict budget.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center