9 Replies Latest reply on Oct 12, 2006 2:38 PM by Newsgroup_User

    calling a function in an imported class - part II

    Level 7
      I had asked about this earlier and got it to work. Now the file that I
      had it working for gets loaded into another movie and it does not work
      anymore. I can still call the validation function and get the trace, but
      it seems like it does not see the variables anymore. How would I modify
      it so it does?

      Thank you for any help.

      The validation function looks like this:

      class mainObj {

      public function validateForm(tName:String, tCompany:String,
      tTitle:String, tAddress:String, tCity:String, tState:String,
      tZip:String, tPhone:String, tEmail:String, tEventcity:String,
      tEventlocation:String, tEvent:String, tEventstartdate:String,
      tEventenddate:String, tLoadindate:String, tStrikedate:String,
      cAudio:Boolean, cVideo:Boolean, cLighting:Boolean, cRental:Boolean,
      tComments:String):Void {
      trace("validate called!");
      if (tName == "" || tName == undefined) {
      this.showAlertMsg("Please enter your name");
      trace("Please enter your name");
      } else if (tCompany == "" || tCompany == undefined) {
      this.showAlertMsg("Please enter your company's name");
      } else if (tPhone == "" || tPhone == undefined) {
      this.showAlertMsg("Please enter your telephone number");
      } else if (tEmail == "" || tEmail == undefined || tEmail.indexOf("@")
      == -1 || tEmail.indexOf(".") == -1) {
      trace("Invalid email address: "+tEmail+" infexOf1:
      "+tEmail.indexOf("@")+" indexOf2: "+tEmail.indexOf("."));
      this.showAlertMsg("Please enter a valid email address");
      } else {
      var e = new LoadVars();


      e.Name = tName;
      e.Company = tCompany;
      e.Title = tTitle;
      e.Address = tAddress;
      e.City = tCity
      e.State = tState;
      e.Zip = tZip;
      e.Phone = tPhone;
      e.FromEmail = tEmail

      e.EventName = tEvent
      e.EventLocation = tEventlocation
      e.EventCity = tEventcity

      e.StartDate = tEventstartdate
      e.EndDate = tEventenddate
      e.LoadInDate = tLoadindate
      e.StrikeDate = tStrikedate

      e.Audio = cAudio
      e.Video1 = cVideo
      e.Lighting = cLighting
      e.Rental = cRental

      e.Comments = tComments

      e.status = "";
      e.sendAndLoad("sendContact.php", e, "Post");
      this.showAlertMsg("Your message has been sent");
      //this.openPage("home");
      //_root.menuMC.contactMC.gotoAndPlay("out");
      gotoAndPlay("contact");
      }
      }
      public function showAlertMsg(msg:String):Void {
      _root.msgBoxMC.msgText = msg;
      _root.msgBoxMC.gotoAndPlay("on");
      }
      }
        • 1. Re: calling a function in an imported class - part II
          VisionaryStudios
          What variables exactly are not seen anymore?
          • 2. Re: calling a function in an imported class - part II
            Level 7
            I think these are not working:

            tName
            tCompany
            etc.

            becaue the trace("validate called!"); is working, but the trace("Please
            enter your name"); is not.

            Thanks for the help!
            • 3. Re: calling a function in an imported class - part II
              VisionaryStudios Level 1
              And let me ask can you describe what you are doing and what error you are getting.

              ie. You are in _root.anMC calling yourClass.e.Audio and getting undefined. Or are you trying something else?
              • 4. Re: calling a function in an imported class - part II
                Level 7
                I am not getting an error at all. I am just not getting the validation.
                You can see the file here, look at the contact form.
                http://www.agilitygraphics.com/clients/amalga/test/

                If I have just the contact form, it works, but once the contact file
                gets loaded into the main file it stops to work. When I test it on my
                desktop, I still get the trace for the main object, so I know, that
                works. That is why I am guessing that the variable are not working.

                Did this answer the question?

                Thanks,
                Brian
                • 5. Re: calling a function in an imported class - part II
                  Level 7
                  I just tested some more and it seems like the if statement is just note
                  working once loaded into the other file. So I still think something
                  about the variables not working in the other movie.

                  if (tName == "" || tName == undefined) {
                  this.showAlertMsg("Please enter your name");
                  trace("Please enter your name");
                  } else if (tCompany == "" || tCompany == undefined) {
                  this.showAlertMsg("Please enter your company's name");
                  } else if (tPhone == "" || tPhone == undefined) {
                  this.showAlertMsg("Please enter your telephone number");
                  } else if (tEmail == "" || tEmail == undefined || tEmail.indexOf("@")
                  == -1 || tEmail.indexOf(".") == -1) {
                  trace("Invalid email address: "+tEmail+" infexOf1:
                  "+tEmail.indexOf("@")+" indexOf2: "+tEmail.indexOf("."));
                  this.showAlertMsg("Please enter a valid email address");
                  } else {
                  var e = new LoadVars();
                  • 6. Re: calling a function in an imported class - part II
                    VisionaryStudios Level 1
                    Well, that would suggest to me that it has nothing to do with your class. Your class looks fine on my end. You get "Validate Called" but no trace that says "Please Enter your name" right?

                    If that is the case then tName is = to something other than "" and undefined. You are passing the variables in from your FLA. Trace the variables and see what is getting passed in. Try your debugger that can help quite a bit too!

                    Greg
                    • 7. Re: calling a function in an imported class - part II
                      Level 7
                      VisionaryStudios, thank you so much for your help.

                      I think you are right, the class just can't see the varialbles anymore.
                      I tried the debugger, but not sure if I am working it right. I could not
                      find the varialbles listed anywhere.

                      How should I trace them?
                      I put a few of these under the first trace in that object and it traces
                      nothing. Like so:
                      trace("validate called!");
                      trace(tName);
                      trace(tCompany);
                      trace(tTitle);

                      So the problem must be with the variables. I think somehow I want
                      everything to happen in the contact file and not the main file that that
                      gets loaded into. How can I do that?

                      Thanks,
                      Brian

                      • 8. Re: calling a function in an imported class - part II
                        VisionaryStudios Level 1
                        Well Brian a few things for you

                        When you trace something trace a string with the variable like so:
                        trace("My name is [" + tName +"]");

                        Without the string in there if tName is empty or a carriage return you would never know it because you can't see them when traced. Also I add the brackets in just to see exactly what the white space in a string might be. You could be lookign for "Hi" in a string and have " Hi", or "Hi ". And you would not know that either without knowing where the output string starts and stops.

                        Second I put your class in a movie and I get traces without a problem. There is nothing wrong with it. You are not pathing something some where correctly.

                        How are you loading the class? What is your call to load it? What is your call when you try to validate a form?? Where is that call located, in a frame in what movieclip? Or on a button in which movie clip?
                        • 9. Re: calling a function in an imported class - part II
                          Level 7
                          VisionaryStudios, thanks again for all your help.

                          I have been fiddling with it this whole time, I think it now it
                          working. The problem indeed with with the variables being empty for some
                          reason. The problem just somehow resolved itself. I am not sure what it
                          was that I did that solved it, but for now, I am happy to have it fixed.
                          Sorry, as this is probably a unsatisfactory answer, but the best I can
                          tell you for now. Thanks so much for the help!
                          B