2 Replies Latest reply on Jan 9, 2008 6:24 AM by SteveH59

    Font array help, please

    SteveH59 Level 1
      Hello

      I am a beginner to Flash and I am wondering if I can create an array so that the fields in my online form are input with the same size text and font style (10pt Arial normal is fine).

      At the moment, font/size do appear slightly different when data is entered in the form, although the Properties panel tells me they are the same.

      Would I do it something like this:

      inputs=[name_txt,email_txt,business_txt,country_txt,message_txt];

      for( var elem in inputs) {

      inputs[elem].fontColor = #ffffff;
      inputs[elem].fontStyle = Arial;
      }

      A the moment, the code I have (which is not wonderful) looks like this:

      var mainTL:MovieClip = this;

      //start off with submit button dimmed <--I don't actually use this
      submit_mc._alpha = 80;


      var dataSender:LoadVars = new LoadVars();


      var dataReceiver:LoadVars = new LoadVars();

      /*
      create listener to 'wake up' submit button <--I don't actually use this
      */

      var formCheck:Object = new Object();
      formCheck.onKeyUp = function() {

      if (name_txt.text != '' &&
      email_txt.text != '' &&
      business_txt.text != '' &&
      country_txt.text != '' &&
      message_txt.text != '') {
      //clear any alert messages
      alert_txt.text = '';
      //enable the submit button
      submit_mc._alpha = 100;
      } else {
      //remain disabled until all fields have content
      submit_mc._alpha = 80;
      }
      }

      Key.addListener(formCheck);

      /*#######SET STYLES FOR TEXT FIELDS <--I don't actually use this#######*/

      //define styles for both normal and focussed
      //set hex values here that work with your site's colors

      var normal_border:Number = 0x000000;
      var focus_border:Number = 0x000000;

      var normal_background:Number = 0xffffff;
      var focus_background:Number = 0xffffff;

      var normal_color:Number = 0x000000;
      var focus_color:Number = 0x000000;


      inputs=[name_txt,email_txt,business_txt,country_txt,message_txt];


      for( var elem in inputs) {
      inputs[elem].border = true;
      inputs[elem].borderColor = normal_border;
      inputs[elem].background = true;
      inputs[elem].backgroundColor = normal_background;
      inputs[elem].textColor = normal_color;


      inputs[elem].onSetFocus = function() {
      this.borderColor = focus_border;
      this.backgroundColor = focus_background;
      this.textColor = focus_color;
      }
      inputs[elem].onKillFocus = function() {
      this.borderColor = normal_border;
      this.backgroundColor = normal_background;
      this.textColor = normal_color;
      }
      }

      Selection.setFocus(name_txt);

      submit_mc.onRelease = function() {

      if (name_txt.text != '' &&
      email_txt.text != '' &&
      business_txt.text != '' &&
      country_txt.text != '' &&
      message_txt.text != '') {
      alert_txt.text='';

      mainTL.play();

      dataSender.name = name_txt.text;
      dataSender.email = email_txt.text;
      dataSender.business = business_txt.text;
      dataSender.country = country_txt.text;
      dataSender.message = message_txt.text;

      dataReceiver.onLoad = function() {
      if (this.response == "invalid") {
      mainTL.gotoAndStop(1);
      alert_txt.text = "Sorry, but your email address appears invalid"
      } else if (this.response == "passed") {
      mainTL.gotoAndStop(4);
      }
      }
      //send data to ASP

      dataSender.sendAndLoad("Email.asp", dataReceiver, "POST");
      } else {

      alert_txt.text = "Please complete all fields";
      }
      }

      Many thanks for any help.

      Steve