A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: If... Else statement, in Flash 4

  1. #1

    If... Else statement, in Flash 4

    I am trying to make this code I got from a tutorial to work on MX, but having trouble... can anybody help? Just need the proper structure of if else if else and I will be on my way.

    code:

    on (release) {
    if (!form-email.length || submit-email.indexOf("@") == -1 || Email.indexOf(".") == -1) {
    EmailStatus = "Please enter a valid E-mail address";
    }
    else if (!form-name.length) {
    EmailStatus = "Please enter your name";
    }
    }
    else if (!form-subject.length) {
    EmailStatus = "Please enter a topic";
    }
    else if (!form-body.length) {
    EmailStatus = "Please enter your comment";
    }
    else {
    loadVariablesNum ("snowMailPHP.php", "0", "Post");
    EmailStatus = "Delivering eMail...";
    }
    }



    EDIT: Added [ as ] tags - see posting guidelines at the top of the forum. jbum
    Last edited by jbum; 10-15-2004 at 05:33 PM.

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    Looks like you had a stray right-curly-bracket in there, after the first else clause. This was terminating your on(release) handler, and causing the remaining else clauses to fall outside of the event handler (and trigger syntax errors, no doubt).

    Consistently indenting your code will make this kind of thing easier to spot.

    code:

    on (release) {
    if (!form-email.length || submit-email.indexOf("@") == -1 || Email.indexOf(".") == -1) {
    EmailStatus = "Please enter a valid E-mail address";
    }
    else if (!form-name.length) {
    EmailStatus = "Please enter your name";
    }
    else if (!form-subject.length) {
    EmailStatus = "Please enter a topic";
    }
    else if (!form-body.length) {
    EmailStatus = "Please enter your comment";
    }
    else {
    loadVariablesNum ("snowMailPHP.php", "0", "Post");
    EmailStatus = "Delivering eMail...";
    }
    }

    Last edited by jbum; 10-15-2004 at 05:39 PM.

  3. #3
    Thanks a bunch! I was scratching my head and wondering why they'd change the basic If statements.

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