A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Input text box

  1. #1
    Member
    Join Date
    Feb 2010
    Posts
    79

    Unhappy Input text box

    Hi guys,

    Here i am using one input text box and one button. In the beginning the button should be invisible. Once i started to type text in input text box, the button should be visible. How to do....

    I used following script. But it's not working. pls help me guys..

    stage.addEventListener(Event.ENTER_FRAME, enter_but_fun);
    function enter_but_fun(Event) {
    if (user_name.text==" ") {
    enter_but.visible==false;
    } else {
    enter_but.visible==true;
    }
    }

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    user_name.addEventListener(Event.CHANGE, enter_but_fun);
    function enter_but_fun(e:Event) {
    var myInput:TextInput = e.currentTarget as TextInput;
    if (myInput.text==" ") {
    enter_but.visible=false;
    } else {
    enter_but.visible=true;
    }
    }
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    A couple of things to make it work, first and most obvious is the "==" within the function. Those are only needed for conditional statements not for setting values to objects/variables. Next would be, to replace the "text" property with a textfields "length", so it would look something like this.

    Actionscript Code:
    function enter_but_fun(e:Event):void {
        if(user_name.length == 1) {
            enter_but.visible = false;
        } else {
            enter_but.visible = true;
        }
    }
    Wile E. Coyote - "Clear as mud?"

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