A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Comparing Variables AS2

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    22

    Unhappy Comparing Variables AS2

    Right now, i have two password fields with variables: pass1 and pass2. I'm making a register button. I need it to be something like:
    if(pass1 == pass2){
    on register_btn release{
    gotoAndStop(2);
    }
    }
    I don't know the correct syntax, please help.

  2. #2
    Senior Member
    Join Date
    Oct 2008
    Posts
    227
    Set the instance names of the to textboxes to 'pass1' and 'pass2'.
    If you place the script on the frame:
    PHP Code:
    register_btn.onRelease = function(){
    if(
    pass1.text == pass2.text){
    gotoAndStop(2);
    }

    If you place it on the button:
    PHP Code:
    on(release){
    if(
    pass1.text == pass2.text){
    gotoAndStop(2);
    }


  3. #3
    Junior Member
    Join Date
    Dec 2009
    Posts
    22
    Excellent, that works! Now. How do i prevent the gotoAndStop(2) part from running if both fields are blank. I tried:
    if (pass1.text == pass2.text && pass1.text != ""){
    execute command here}
    However, it doesn't work

  4. #4
    Senior Member
    Join Date
    Oct 2008
    Posts
    227
    That should work. But keep in mind that will only disallow 'pass1' from beeing empty.
    PHP Code:
    if (pass1.text == pass2.text && pass1.text != "" && pass2.text != ""){
    //If 'pass1' matches 'pass2' AND neither are empty, continue. 

  5. #5
    Junior Member
    Join Date
    Dec 2009
    Posts
    22
    Hoorah, it worked! (idk why i didn't think of checking both fields DUH) Thanks very much, Vexy. Look forward to my next posts. >:]

  6. #6
    Senior Member
    Join Date
    Oct 2008
    Posts
    227
    Yay
    That's been my response to 99% of all script issues I've had too, after hours of pulling my hair out: "DUH"

Tags for this Thread

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