A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: This is starting to drive me crazy.

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    10

    This is starting to drive me crazy.

    Ive been trying to create a simple contact form for ages now.

    However the action script seems to be wrong and i cant fix the thing.

    All i want is for when any of the three input txt boxes and blank or the @ or . symbol isnt present in the email box for it to play from label invalid.

    Else play from valid label and use the email script.

    However it always plays valid no matter what...

    pretty sure it isnt a label issue as ive tested that.



    Below is my code

    on (release) {
    if ((!txtName.text.length) || (txtFrom.text.length) || (txtMessage.text.length) ||(txtFrom.text.indexOf("@") == -1) || (txtFrom.text.indexOf(".") == -1))
    {
    loadVariablesNum("cdontsMail.asp", 0, "POST");
    gotoAndPlay("valid");
    }
    else
    {
    gotoAndPlay("invalid");
    }
    }


    can somebody please helpo me or give me advice?

  2. #2
    Senior Member
    Join Date
    May 2010
    Posts
    178
    Actionscript Code:
    btn.onRelease = function() {
        var searchString:String = txtFrom.text;
        if ((txtName.text.length) && (txtFrom.text.length) && (txtMessage.text.length) && (searchString.indexOf("@") != -1) && (searchString.indexOf(".") != -1)) {
            trace("Found");
        } else {
            trace("Sorry");
        }
    };

  3. #3
    Junior Member
    Join Date
    Sep 2010
    Posts
    10
    i just put that in the action layer of the scence, and still have the problem, still just plays the valid section. also tried it with the frame number instead of a label but no look, so definatly the good, but im stumped.. thanks for your help..

    do you have any more ideas?

  4. #4
    Senior Member
    Join Date
    May 2010
    Posts
    178
    can u post an example of your problem?

    OR

    You just take a fresh fla and paste the code with elements and try

    Here, it works fine on AS2


    You can test this attachment
    Last edited by poltuda; 10-28-2010 at 08:18 AM.

  5. #5
    Junior Member
    Join Date
    Sep 2010
    Posts
    10
    Ive attached the file.

    hope u understand what i mean..

    every tutorial ive tried always has the same problem, i just dont know what im doing wrong. and its driving me round the bend now.

    all im trying to do is to get it to show the invalid label when the text boxes are blank and the txtfrom doesnt contain a @ sign.

    Thanks for your help
    Attached Files Attached Files

  6. #6
    Senior Member
    Join Date
    May 2010
    Posts
    178
    Re Post in CS3 Format. I have CS3 only

  7. #7
    Junior Member
    Join Date
    Sep 2010
    Posts
    10
    cs5 will only let me do it as cs4 and cs5? ... is there any other way?

  8. #8
    Senior Member
    Join Date
    May 2010
    Posts
    178
    Post the swf

  9. #9
    Junior Member
    Join Date
    Sep 2010
    Posts
    10
    here is the swf.

    the code on my button is

    on (release) {
    if ((!txtName.text.length) || (txtFrom.text.length) || (txtMessage.text.length) ||(txtFrom.text.indexOf("@") == -1) || (txtFrom.text.indexOf(".") == -1))
    {
    loadVariablesNum("cdontsMail.asp", 0, "POST");
    gotoAndPlay("valid");
    }
    else
    {
    gotoAndPlay("invalid");
    }
    }


    trying to get screenshots but my comp only takes screenshot of top half of flash for somereason....
    Attached Files Attached Files

  10. #10
    Junior Member
    Join Date
    Sep 2010
    Posts
    10
    Here are some screen shots, hope they help.

    thanks for helping by the way
    Attached Images Attached Images

  11. #11
    Senior Member
    Join Date
    May 2010
    Posts
    178

    Suggestion

    As your swf, it seems that the text field of email having embedded fonts which cause to refuse the @ sign. it is my suggestion that don't embed fonts unnecessarily. By seeing your screen shots it looks you also construct valid/invalid frames which can be done by replace the text of success message. That will take only one frame to do the whole thing.There must somewhere you mistake or might use same code in different places, which conflict.

    I think the code bellow will work properly:

    Actionscript Code:
    on (release) {
    if ((txtName.text.length) && (txtFrom.text.length) && (txtMessage.text.length) && (searchString.indexOf("@") != -1) && (searchString.indexOf(".") != -1)) {

    loadVariablesNum("cdontsMail.asp", 0, "POST");
    gotoAndPlay("valid");
    trace("Found");
    }
    else
    {
    gotoAndPlay("invalid");
    trace("Sorry");
    }
    }

    OR, if you place all things in one frame then use the code bellow:

    Actionscript Code:
    on (release) {
    if ((txtName.text.length) && (txtFrom.text.length) && (txtMessage.text.length) && (searchString.indexOf("@") != -1) && (searchString.indexOf(".") != -1)) {

    loadVariablesNum("cdontsMail.asp", 0, "POST");
    warning.text="valid";
    }
    else
    {
    warning.text="invalid";
    }
    }

    Best of luck.

    poltuda

  12. #12
    Junior Member
    Join Date
    Sep 2010
    Posts
    10
    got it working. including text field thanks very much for all your help

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