A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] [F8] Help with Input Text Variable

  1. #1
    Junior Member
    Join Date
    Jun 2008
    Posts
    18

    resolved [RESOLVED] [F8] Help with Input Text Variable

    Code:
    answerbtn.onRelease = function()
    {	
    if (userinput == 2)
    	{
    		gotoAndPlay("easycorrect");	
    	}
    else 
    	{
    		gotoAndPlay("easyincorrect");
    	}	
    }
    "userinput" is a input text box with "userinput" as its variable name.

    when you click the button (answerbtn) it should compare the userinput data with "2", and if its the same, go to "easycorrect", else "easyincorrect"

    I have double checked all the names of the elements.
    I also tried to create a new variable and store the userinput inside, but that didn't seem to work.
    I also replaced "2" with "hello", because I thought it might be a str/int problem, but that didn't work either.
    I checked the help, and the operators/etc seem to be correct.

    Everytime I play it, it goes to easyincorrect no matter what text I enter.

    Can anyone help me out? Thanks
    Attached Files Attached Files
    Last edited by midnightheist; 08-30-2008 at 01:30 AM. Reason: attachment of fla

  2. #2
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160

    try this

    remove Auto kern from your textbox(userinput) property panel.

  3. #3
    Junior Member
    Join Date
    Jun 2008
    Posts
    18
    Haha. That's pretty ridiculous xD Thanks a bunch.

    Whats the point of auto-kern?
    And why can't flash read the text box if it's turned on?

  4. #4
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    did you try that??

    ...well, when you use autokern for a textbox, you can sometimes find that when you try to trace the value entered inside the textbox it does not show you the input value but the whole textbox formatting.. example textbox font,line spacing, font size etc etc. Hence if you enter a value "5" in the textbox(userinput) and try to do this:
    userinput+5, it wil not show you 5+5=10, but (5+text format styles)....
    SO the resultant is not a number, it wil be some string...
    Hence you have this problem, everytime the if statement fails to recognise it as a number.

  5. #5
    Junior Member
    Join Date
    Jun 2008
    Posts
    18

    Question operator variable problem

    Yup, works nicely, thanks.

    I have attached some updated code, with an additional problem that has come up.

    Code:
    stop();
    
    switchvar = random(0);
    
    switch(switchvar)
    {
    case 0:
    	operator = "+";
    	num1 = random(10);
    	num2 = random(10);
    	break;
    
    case 1:
    	operator = "-";
    	num1 = random(10);
    	num2 = random(num1);
    	break;
    }
    
    
    answerbtn.onRelease = function()
    {	
    if ((num1 operator num2) == userinput)
    	{
    		//gotoAndPlay("easycorrect");		
    		_root.bunny._alpha = 0;
    	}
    else 
    	{
    		//gotoAndPlay("easyincorrect");
    		_root.bunny._alpha = 50;
    	}	
    }
    I need to use a variable that stores and uses a operator (in this case addition or subtraction(+ or -)), but I am unsure how to do this in flash.

    How can I get this working?
    Thanks
    Attached Files Attached Files
    Last edited by midnightheist; 08-31-2008 at 08:44 PM.

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