Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Input texfields problem

    please help me. i made an input textfield with an instance name of "ans".
    i want that if the user input the word "table" in it, an object on the stage will disappear. else it will go to frame 1. but everytime i test the movie it always go to frame 1 even if i input the word "table". please please help me guys -_-.
    heres my code:

    stage.addEventListener(KeyboardEvent.KEY_UP, willhide);

    function willhide(e:KeyboardEvent):void {
    if(e.keyCode == Keyboard.ENTER){
    if (ans.text == "table") {
    p1_1.visible=false;

    } else {
    gotoAndStop(1);
    }
    }
    }

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,372
    Thanks
    32
    Thanked 286 Times in 280 Posts
    Quote Originally Posted by cfbaw View Post
    i want that if the user input the word "table" in it, an object on the stage will disappear. else it will go to frame 1. but everytime i test the movie it always go to frame 1 even if i input the word "table". please please help me guys -_-.
    In a two-keyframe file with a circle (myCircle), text field (myTextField), and ActionScript assigned assigned to keyframe two, this code works for me:

    Code:
    stop();
    function hideObjectOrGoToFrame1(keyUpEvent:KeyboardEvent):void {
    	if (keyUpEvent.keyCode === Keyboard.ENTER) {
    		if (myTextField.text === "table") {
    			myCircle.visible = false;
    		}
    		else {
    			gotoAndStop(1);
    		}
    	}
    } 
    stage.addEventListener(KeyboardEvent.KEY_UP, hideObjectOrGoToFrame1);
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

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