1 Reply Latest reply: Apr 6, 2011 10:26 AM by kglad RSS

    Coding for static fill-out form

    ruthgordy Community Member

      fill out form questionnaire?

       

      I am creating in Flash CS4 (AS3) a static fill out form for a website that I am involved in. The questionnaire helps to determine whether a person is suseptible to drug and alcohol abuse with either a postive answer (not likely to develop substance abuse) or a negative answer (likely to develop substance abuse)

       

      There are six questions on this form that MUST be answered either yes or no.

      I have created the form with all art and buttons and it is ready to implement in Dreamweaver but need the scripting to make work.

       

      The six YES buttons are assigned instance names of cb1, cb3, cb5, cb7, cb9 and cb11

      The six NO buttons are assigned instance names of cb2, cb4, cb6, cb8, cb10

      and cb12.

      When the participant answers all six questions either yes or no they will hit a Submit button (with an instance name of submit) that will direct them to a new web/flash page with appropriate answer.

       

      If the participant answers TWO or more questions with YES and hit submit they will be directed to a new page/doc in the website with the negative answer.

       

      If the participant answers ONE YES and hit submit they will be directed to a new page/doc in the website with a positive answer.

       

      If the participant answers ALL NO and hit submit they will be directed to a new page/doc in the website with the same positive answer as answering with ONE YES response.

       

      I assume this is a very complex coding problem. I am a beginner/intermidiate flash person with extreme novice understanding of coding. I know what stop(); does in AS3 and understand simple clickTag coding etc.

      Would appreciate any help with AS3 coding for this document.

      I usually find coding on forums like these and online blogs - but I don't even know where to begin looking.

       

      Thanks

        • 1. Re: Coding for static fill-out form
          kglad CommunityMVP

          on the timeline that contains your buttons:

           

          var yesNum:int=0;

          var noNum:int=0;

           

          submit_btn.addEventListener(MouseEvent.CLICK,submitF);

           

          for(var i:int=1;i<=12;i++){

          if(1%2==0){

          this["cb"+i].addEventListener(MouseEvent.CLICK,noF);

          } else {

          this["cb"+i].addEventListener(MouseEvent.CLICK,yesF);

          }

          }

           

          function yesF(e:MouseEvent):void{

          yesNum++;

          e.currentTarget.removeEventListener(MouseEvent.CLICK,yesF);

          }

          function yesF(e:MouseEvent):void{

          noNum++;

          e.currentTarget.removeEventListener(MouseEvent.CLICK,noF);

          }

           

          function submitF(e:MouseEvent):void{

          if(yesNum+noNum==12){

          // take appropriate action based on yesNum and/or noNum

          } else {

          // error.  all questions not answered.

          }

          }