3 Replies Latest reply on Jun 5, 2008 7:05 AM by kglad

    Flash Vars to PHP

    jon gibbons
      Dear Sirs,
      This script seems to work? i get the message sent... but then the php is not picking up the Vars, i inputed the $ tag to vars. the php text comes out but without the loaded vars.
      if this script is ok, then it will be the php script. can someone just browser though the code. much appreciated.


      import mx.controls.TextInput;
      import mx.controls.RadioButton;
      import mx.controls.RadioButtonGroup;
      import mx.controls.ComboBox;
      import mx.controls.DateField;
      // import the required component classes.
      import mx.controls.*;

      // define the component instances on the Stage.
      var Title:ComboBox;
      var Forename1:TextInput;
      var Surname1:TextInput;
      var Address1:TextArea;
      var Country1:TextInput;
      var Post_code1:TextInput;
      var Home_Phone1:TextInput;
      var Mobile_Phone1:TextInput;
      var Fax1:TextInput;
      var E_Mail1:TextArea;
      var clear_button:mx.controls.Button;
      var submit_button:mx.controls.Button;
      var Department1:ComboBox;
      var arrival_date:DateField;
      var depature_date:DateField;
      var rooms_combo:ComboBox;
      var availability_button:mx.controls.Button;
      var Honeymoon_Suite:ComboBox;
      var Delux_villa:ComboBox;
      var Superior_room:ComboBox;
      var Guest_Adult:ComboBox;
      var Under_3:ComboBox;
      var Below_15:ComboBox;
      var Transfers:RadioButtonGroup;
      var Transfers_Yes:RadioButton;
      var Transfers_No:RadioButton;
      var Port_in:ComboBox;
      var Port_Out:ComboBox;
      var time_arival:TextInput;
      var Login:TextInput;
      var Password:TextInput;

      // set the tabbing order for the components
      this.Title.tabIndex = 1;
      this.Forename1.tabIndex = 2;
      this.Surname1.tabIndex = 3;
      this.Address1.tabIndex = 4;
      this.Country1.tabIndex = 5;
      this.Post_code1.tabIndex = 6;
      this.Home_Phone1.tabIndex = 7;
      this.Mobile_Phone1.tabIndex = 8;
      this.Fax1.tabIndex = 9;
      this.E_Mail1.tabIndex = 10;
      this.clear_button.tabIndex = 11;
      this.submit_button.tabIndex = 12;
      this.Department1.tabIndex = 13;
      this.arrival_date.tabIndex = 14;
      this.departure_date.tabIndex = 15;
      this.rooms_combo.tabIndex = 16;
      this.Honeymoon_Suite.tabIndex = 17;
      this.Delux_villa.tabIndex = 18;
      this.Superior_room.tabIndex = 19;
      this.Guest_Adult.tabIndex = 20;
      this.Under_3.tabIndex = 21;
      this.Below_15.tabIndex = 22;
      this.Transfer_Yes.tabIndex = 23;
      this.Transfer_No.tabIndex = 24;
      this.Port_in.tabIndex = 25;
      this.Port_Out.tabIndex = 26;
      this.time_arrival.tabIndex = 27;
      this.Login.tabIndex = 28;
      this.Password.tabIndex = 29;

      // set the default form focus to the name_ti TextInput instance, and set the default button to the submit button.
      Selection.setFocus(Forename1);
      focusManager.defaultPushButton = submit_button;

      // when the clear button is clicked, set the form fields to empty strings.
      var clearBtnListener:Object = new Object();
      clearBtnListener.click = function(evt:Object) {
      Forename1.text = "";
      Surname1.text = "";
      Address1.text = "";
      Country1.text = "";
      Post_code1.text = "";
      Home_Phone1.text = "";
      Mobile_Phone1.text = "";
      Fax1.text = "";
      E_Mail1.text = "";
      time_arrival.text = "";
      Login.text = "";
      Password.text = "";
      };
      this.clear_button.addEventListener("click", clearBtnListener);

      // when the submit button is clicked, send the form values to the server using a LoadVars object.
      var postBtnListener:Object = new Object();
      postBtnListener.click = function(evt:Object) {
      // if the name is blank, display an error message using the Alert component.
      if (Forename1.text.length == 0) {
      Selection.setFocus(Forename1);
      Alert.show("Please enter your Forename.", "Error", Alert.OK);
      return false;
      }
      if (Surname1.text.length == 0) {
      Selection.setFocus(Surname1);
      Alert.show("Please enter your Surname.", "Error", Alert.OK);
      return false;
      }
      if (Address1.text.length == 0) {
      Selection.setFocus(Address1);
      Alert.show("Please enter your Address.", "Error", Alert.OK);
      return false;
      }
      if (Country1.text.length == 0) {
      Selection.setFocus(Country1);
      Alert.show("Please enter your Country.", "Error", Alert.OK);
      return false;
      }
      if (Post_code1.text.length == 0) {
      Selection.setFocus(Post_code1);
      Alert.show("Please enter your Post Code.", "Error", Alert.OK);
      return false;
      }
      if (Home_Phone1.text.length == 0) {
      Selection.setFocus(Home_Phone1);
      Alert.show("Please enter your Home Phone Number.", "Error", Alert.OK);
      return false;
      }
      if (Mobile_Phone1.text.length == 0) {
      Selection.setFocus(Mobile_Phone1);
      Alert.show("Please enter your Mobile Phone Number.", "Error", Alert.OK);
      return false;
      }
      if (E_Mail1.text.length == 0) {
      Selection.setFocus(E_Mail1);
      Alert.show("Please enter your E Mail Address.", "Error", Alert.OK);
      return false;
      }
      if (arrival_date.text.length == 0) {
      Selection.setFocus(arrival_date);
      Alert.show("Please enter your Arrival Dtae.","Error",Alert.OK);
      return false;
      }
      if (departure_date.text.length == 0) {
      Selection.setFocus(departure_date);
      Alert.show("Please enter your Departure Date.","Error",Alert.OK);
      return false;
      }
      // if all the required fields have been filled in, create a LoadVars object instance and populate it.
      var send_lv:LoadVars = new LoadVars();
      send_lv.Title = Title.text;
      send_lv.Forename1 = Forename1.text;
      send_lv.Surname1 = Surname1.text;
      send_lv.Address1 = Address1.text;
      send_lv.Country1 = Country1.text;
      send_lv.Post_code1 = Post_code1.text;
      send_lv.Home_Phone1 = Home_Phone1.text;
      send_lv.Mobile_Phone1 = Mobile_Phone1.text;
      send_lv.Fax1 = Fax1.text;
      send_lv.E_Mail1 = E_Mail1.text;
      send_lv.Department1 = Department1.text;
      send_lv.arrival_date = arrival_date.selectedDate;
      send_lv.departure_date = departure_date.selectedDate;
      send_lv.rooms_combo = rooms_combo.text;
      send_lv.Honeymoon_Suite = Honeymoon_Suite.text;
      send_lv.Delux_villa = Delux_villa.text;
      send_lv.Superior_room = this.Superior_room.text;
      send_lv.Guest_Adult = Guest_Adult.text;
      send_lv.Under_3 = Under_3.text;
      send_lv.Below_15 = Below_15.text;
      send_lv.Transfer_Yes = Transfer_Yes.selected;
      send_lv.Transfer_No = Transfer_No.selected;
      send_lv.Port_in = Port_in.text;
      send_lv.Port_Out = Port_Out.text;
      send_lv.time_arrival = time_arrival.text;
      send_lv.Login = Login.text;
      send_lv.Password = Password.text;
      send_lv.onLoad = function(success:Boolean) {

      // if the comments were sent to the server and you received a response, clear the form fields and display an Alert message.
      if (success) {
      Title1.text = "";
      Forename1.text = "";
      Surname1.text = "";
      Address1.text = "";
      Country1.text = "";
      Post_code1.text = "";
      Home_Phone1.text = "";
      Mobile_Phone1.text = "";
      Fax1.text = "";
      E_Mail1.text = "";

      Alert.show("Thank you for your comments.", "Success", Alert.OK);
      } else {
      // else you encountered an error while submitting to the server.
      Alert.show("Unable to process your comments at this time.", "Server Error", Alert.OK);
      }
      };
      // send the variables from Flash to the remote PHP template.
      send_lv.sendAndLoad(" http://www.???????????.com/handle_form.php",send_lv,"POST");
      };
      this.submit_button.addEventListener("click",postBtnListener);
        • 1. Re: Flash Vars to PHP
          kglad Adobe Community Professional & MVP
          are your variable/values received in your swf?
          • 2. Re: Flash Vars to PHP
            jon gibbons Level 1
            i added a trace statement:

            trace(Title.text);
            trace(Forename1.text);
            trace(Surname1.text);
            trace(Address1.text);
            trace(Country1.text);
            trace(Post_code1.text);
            trace(Fax1.text);
            trace(Home_Phone1.text);
            trace(Mobile_Phone1.text);
            trace(E_Mail1.text);
            trace (send_lv);

            which returns this message in the output window.?????


            Mr
            jonathan
            gibbons
            orchard house
            east lound
            haxey
            doncaster
            england
            dn9 2lr
            076 286 161
            01427 752185
            0872 398 161
            gibbo_960@hotmail.com
            onLoad=%5Btype%20Function%5D&Password=Password&Login=Login&time%5Farrival=Flight%20No%2E%2 0or%20Est%20Time%20of%20Arrival%20%2D9%2E00%20am&Port%5FOut=Pai%20Airport&Port%5Fin=Pai%20 Airport&Transfer%5FNo=false&Transfer%5FYes=true&Below%5F15=2&Under%5F3=2&Guest%5FAdult=4&S uperior%5Froom=undefined&Delux%5Fvilla=Deluxe%20Villa&Honeymoon%5FSuite=2&rooms%5Fcombo=2& departure%5Fdate=Thu%20Jun%2019%2000%3A00%3A00%20GMT%2B0700%202008&arrival%5Fdate=Mon%20Ju n%2016%2000%3A00%3A00%20GMT%2B0700%202008&Department1=Arayaburi%20Boutique%20Resort&E%5FMa il1=gibbo%5F960%40hotmail%2Ecom&Fax1=076%20286%20161&Mobile%5FPhone1=0872%20398%20161&Home %5FPhone1=01427%20752185&Post%5Fcode1=dn9%202lr&Country1=england&Address1=orchard%20house% 0Deast%20lound%0Dhaxey%0Ddoncaster&Surname1=gibbons&Forename1=jonathan&Title=Mr

            i named the components as above, these are not the corresponding var name???
            • 3. Re: Flash Vars to PHP
              kglad Adobe Community Professional & MVP
              use a different loadvars instance to receive.