4 Replies Latest reply on Oct 15, 2006 4:31 PM by kglad

    Coding Problem

      I am trying to write the Actionscript for a "Send" button, on a simple "Contact" form.

      Here's what I'm trying to achieve:

      If the required text fields on the form aren't filled in,
      then the Send button should take the user to the "ContactError" slide screen in my .fla file.

      If the form is filled out correctly,
      the Send button should take the user to the "ContactCorrect" slide screen

      What's wrong with my code???? Is there a glaring error? Can someone check this out:
      Here's the Actionscript on the send button:

      // onRelease
      this.on (release) = function() {
      if (this.userName.text == "" || this.userEmail.text == "" || this.userMessage.text == "") {
      gotoScreen ("contactError");

      } else {
      gotoScreen ("contactCorrect");

        • 1. Re: Coding Problem
          What is the error saying when you compile?

          You said you are trying to write scripts for a "Send" button. The keyword "this" usually is refrained for movie clips, as it's a path to a movie clip.

          If you're writing clip events for a button, you would write mySend_btn.onRelease = function() {.... }

          I did not find the "gotoScreen" clipevent in the Help Docs. What version of Flash are you using?
          • 2. Re: Coding Problem
            Level 7
            You're missing a closing } to close the function.

            Dave -
            Adobe Community Expert

            • 3. Re: Coding Problem
              heidi37 Level 1
              Thanks so much for the feedback (I am using Flash Professional 8), I think I'm closer now,
              but I am still getting two Error messages, as follows:

              **Error** Screen=contact, layer=form, frame=1:Line 2: Statement must appear within on handler
              this.onRelease = function() {

              **Error** Screen=contact:Line 10: Statement must appear within on/onClipEvent handler

              I am new to Actionscript, and not sure what these Error messages mean...

              Here's the updated script:

              // onRelease
              this.onRelease = function() {
              if (this.userName.text == "" || this.userEmail.text == "" || this.userMessage.text == "") {
              gotoAndStop (this._parent.contactError);
              } else {
              gotoAndStop (this._parent.contactCorrect);
              • 4. Re: Coding Problem
                kglad Adobe Community Professional & MVP
                your code should be attached to a frame on the timeline of your movieclip button. and you'll probably want to label frames "contactError" and "contactCorrect" on the parent timelineof your movieclip and use: