15 Replies Latest reply on Jul 11, 2008 3:10 PM by kglad

    Problems with Combo Box

    Graphic_Guy08 Level 1
      I'm working on a web site for my employer and I've run into some difficulties using ActionScript due to my lack of prior experience with it (before this job, I have only done limited work with Flash on web sites, either simple animations or applications from templates, like the photo viewer). I'm trying to create an application in Flash that will take the data from a Combo Box and, when the user presses the submit button, it will display a different frame with an image of the product and the revelant information. I've tried using if/else/else if syntax (as shown), the result is either it does nothing or it only brings up the final item. Any assistance that can be provided is greatly appreciated, I know my employers want to get this site uploaded A.S.A.P.

      Also, I am trying to set up the final item on this list as a form for data to be submitted by e-mail. I know this could be easily done in HTML, and I did suggest that to my employer, but they prefer the asthetic quality of having everything contained in the Flash application. The problem I am having with this e-mail submission is that rather than simply sending the data that is in the text fields, it opens a blank new window using my default e-mail program. The syntax for this application is also shown. Again, any help that can be provided would be greatly appreciated. Thanks.

        • 1. Re: Problems with Combo Box
          kglad Adobe Community Professional & MVP
          use double equal (==) to test for equality. otherwise, you're using the assignment operator.

          to send email and not use the default email you need to use some server-side script like php.
          • 2. Re: Problems with Combo Box
            Graphic_Guy08 Level 1
            I tried the double equal sign, neither of those syntaxes work with it - any further suggestions? I also tried adding some syntax from a tutorial on using PHP to e-mail Flash forms, it still brings up a blank e-mail window using my default program.

            The syntax was:
            form.loadVariables("Innerflow/email.php", "POST");

            with a PHP file with the following code:
            $myfrom = $email;
            $myemail = "youemail@hotmail.com";
            $todayis = date("l, F j, Y, g:i a") ;
            $subject= "Message From Website";
            $message = "
            Date : $todayis
            Name: : $name
            company: : $company
            phone: : $phone
            email: : $email
            comments : $comments
            $from = "From: $myfrom\r\n";
            mail($myemail, $subject, $message, $from);
            $subject2="Thanks for contacting me.";
            $message2="Dear $name,
            Thanks for contacting me, I will respond you shortly.";
            $from2 = "From: $myemail\r\n";
            mail($email, $subject2, $message2, $from2);

            Any further suggestions would be greatly appreciated, I really need to get this done.
            • 3. Re: Problems with Combo Box
              kglad Adobe Community Professional & MVP
              use the trace() function to pinpoint your problem. then if you're unable to solve it, indicate the location of the problem
              • 4. Re: Problems with Combo Box
                Graphic_Guy08 Level 1
                Thanks, the trace function code has definitely helped out. Currently I have the following code:

                // Adds conditional logic for the Combo Box that validates user input.
                function change(evt){

                var cbListener:Object = new Object();
                models_cb.addEventListener("change", cbListener);

                cbListener.change = function(event_obj:Object) {
                trace("Value changed to: "+event_obj.target.selectedItem.data);

                The only problem remaining is that this applies the function directly to the Combo Box - my employers are not satisfied with this result and insist that the Combo Box only link to the Submit button, which (when pressed) will then complete the function. Any suggestions?

                I'm also still trying to work out the e-mail issue, let me know if you can provide any further support in that regard. Thanks
                • 5. Re: Problems with Combo Box
                  kglad Adobe Community Professional & MVP
                  if you want a submit button (say, submitBtn) to direct your timeline to the keyframe determined by the comboboxes data, use something like:

                  • 6. Re: Problems with Combo Box
                    Graphic_Guy08 Level 1
                    I copied that code from this page, just changed the button name to match my instance name, it doesn't work. It still brings up the trace for each item in the ComboBox, but the Submit button still does not do anything, plus the frame doesn't display with that code. I'm running Flash 8, using (obviously) ActionScript 2, if that makes a difference.
                    • 7. Re: Problems with Combo Box
                      Graphic_Guy08 Level 1
                      Nevermind, I got it to work, I must have been doing something wrong. Thanks very much for your help, I will post again if I have any issues with the e-mailing portion of the app, but the main problem is solved. Thanks again.
                      • 8. Re: Problems with Combo Box
                        kglad Adobe Community Professional & MVP
                        you're welcome.
                        • 9. Re: Problems with Combo Box
                          Graphic_Guy08 Level 1
                          So the e-mail part of the app still doesn't work. I'm not really sure what you meant with your last comment about my PHP script. I am currently using.the following syntax:

                          // Adds conditional logic for the Unlisted Model Form's Submit button that validates user input.
                          this.submit2_btn.onRelease = function(){
                          if (fullname_txt.text == null || fullname.text =="" or email_txt.text == null || email_txt.text =="" or
                          phone_txt.text == null || phone_txt.text =="" or brand_txt.text == null || brand_txt.text =="" or
                          acmodel_txt.text == null || acmodel_txt.text =="" or height_txt.text == null || height_txt.text =="" or
                          width_txt.text == null || width_txt.text =="" or depth_txt.text == null || depth_txt.text ==""){
                          } else {
                          form.loadVariablesNum("email.php", 0, "POST");

                          // Converts form data to PHP language for e-mailing to us.
                          function lineAdapt(){
                          fullname_txt = fullname;
                          email_txt = email;
                          phone_txt = phone;
                          brand_txt = brand;
                          acmodel_txt = acmodel;
                          height_txt = height;
                          width_txt = width;
                          depth_txt = depth;
                          while (msg_count<length(message)){
                          msg_count = msg_count+1;
                          if ((substring(message_send, msg_count, 2)) eq ""){
                          message_send = (substring(message_send, 1, msg_count-2)) +""+ (substring(message_send, msg_count+2,

                          and the following script in a file called email.php (the file was created in Dreamweaver 8):

                          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                          <html xmlns=" http://www.w3.org/1999/xhtml">
                          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                          <title>Untitled Document</title>

                          mail("ryan@villaolympic.com", $fullname, $email, $phone, $brand, $acmodel, $height, $width, $depth, "From: PHPMailer
                          Reply-To: $email
                          X-Mailer: PHP/" . phpversion());

                          Again, any support you can offer would be greatly appreciated.
                          • 10. Re: Problems with Combo Box
                            Graphic_Guy08 Level 1
                            Oh, also, in the tutorials I've read, it suggested posting the Flash app and the PHP file to the server to do the test - will my test really not work unless the files are on the server, or can I make sure this will work before that?
                            • 11. Re: Problems with Combo Box
                              kglad Adobe Community Professional & MVP
                              if you don't have php installed and your localhost set-up to act as a server, you can't test locally.

                              in addition, there are problems with your actionscript and with your php.

                              first, it's not clear anything (like fullname, email etc) is defined in form. it's easier to control things using the loadvars class.

                              2nd, that php script isn't going to work. if you use the loadvars class and POST your variables, try:

                              • 12. Re: Problems with Combo Box
                                Graphic_Guy08 Level 1
                                It's still not working (or at least not that I can tell, I don't know if we have PHP installed if localhost is the server). I did find some ActionScript that uses LoadVars though, here it is:

                                // Converts form data to PHP language for e-mailing to us.
                                var gatherForm:LoadVars = new LoadVars();
                                function sendForm() {
                                gatherForm.email_to = "ryan@villaolympic.com";
                                gatherForm.visitor_name = _root.container.form.fullname_txt.text;
                                gatherForm.visitor_email = _root.container.form.email_txt.text;
                                gatherForm.visitor_phone = _root.container.form.phone_txt.text;
                                gatherForm.visitor_brand = _root.container.form.brand_txt.text;
                                gatherForm.visitor_acmodel = _root.container.form.acmodel_txt.text;
                                gatherForm.visitor_height = _root.container.form.height_txt.text;
                                gatherForm.visitor_width = _root.container.form.width_txt.text;
                                gatherForm.visitor_depth = _root.container.form.depth_txt.text;
                                gatherForm.sendAndLoad("email.php", gatherForm, "POST");

                                I've tried it both with your PHP and the PHP that was listed with it (I found it on a web forum, I'm basically limited to that and the textbooks I have available, one of which is scrictly for ActionScript). Do I need to turn on script error notification in Internet Explorer to see if it echoes back? Sorry to be such a pain, this is the last major application I need to get done for this web site for launch.
                                • 13. Re: Problems with Combo Box
                                  kglad Adobe Community Professional & MVP
                                  use a different loadvars instance for the send and for the load. and for testing you might want to use an onData() method to see if success or failure is being echoed.
                                  • 14. Re: Problems with Combo Box
                                    Graphic_Guy08 Level 1
                                    OK, so I have replaced all the gatherForm instances in my last post with senderLoad, and created a new variable that states var receiveLoad:LoadVars = new LoadVars(); - I assume that's what you meant when you suggested using different LoadVars instances, if not I'm not really sure what you mean. Oh, and I'm totally confused on how to implement the onData() instance. Please let me know if you can. Thanks.