A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: AS2 - Checking input box data problem

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    3

    AS2 - Checking input box data problem

    Hi, ive searched for answers to my problem for a while now but i just cant seem to find a quick and simple solution.

    Here's my set up and problem;

    I have 1 input box (instance name 'num5'),
    1 button (with AS2 on it),

    what i want to work;

    when i enter '100' in the box (run some code)
    when i enter more than 100 (run some different code)
    when i don't enter anything (run different code again)

    So far i have this actionscript on my button;

    Code:
    on (release){
    	if (num5.text == "100"){
    		trace("1");
    	}
    	else if (Number(num5) > 100){
    		trace("2");
    	}
    	else if (num5 == null){
    		trace("3");
    	}	
    }
    the code within the if statements will be changed once i have this working, but for now trace is an easy way to test.

    As you can see i have the first statement 'kind of' working, its cheating a bit but it works. Its the null and > 100 that i just dont know how to get working.

    I've seen in some other places that i need to convert the string in the text box to a number or something along those lines, but really im quite lost, im not new to coding in general, but i know almost nothing about actionscript.

    Can anyone help me out here? Thanks

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    AS2, Flash Player 7
    Code:
    on (release) {
    	if (Number(num5.text) == 100) {
    		trace("1");
    	} else if (Number(num5.text)>100) {
    		trace("2");
    	} else if (isNaN(Number(num5.text))) {
    		trace("3");
    	} else {
    		trace("4");
    	}
    }

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    3
    Thanks a lot! That was exactly what i needed, wish i had come here first!

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