2 Replies Latest reply on Jun 14, 2008 8:54 AM by SteveH59

    TextArea - changes its values

    SteveH59 Level 1

      A kind soul here suggested using a TextArea component on a form. It will appear as the 'message' field of the form, alongside 'name', 'business', etc.

      If I tab through the other fields (when focus in on them) the border of these fields changes from white to purple - my required colour. The default font colour for the form fields is white.

      But when it comes to my TextArea message box, I have a kind of green colour with a marine font.

      I understand that to change this I have to use something like the following where message_txt (an input text box) is the instance name of the TextArea component:

      var my_styles = new TextField.StyleSheet();

      message_txt.setStyle("p", {fontFamily:'Arial', fontSize:'11px', color:'#ffffff'});
      _global.styles.TextArea.backgroundColor = '#3C3C3C';
      message_txt.styleSheet = my_styles;

      I am not sure, however, about the border property. I need to be able to define its width, and the changes with regard to the focus as I have indicated above.

      I am also not sure about where to place this script. Do I click on the TextArea itself and paste it into the Actions Script panel? Or do I need to create a new layer especially for this component and then paste it into the AS panel (I have AS2 with MX 2004)?

      At the moment the form comprises two layers: one for the form/server side of things, and the other for the text decoration itself. The AS for this is:

      //TextField Styles
      normal_border = 0xFFFFFF
      select_border = 0xBDA0F2
      normal_background = 0x3C3C3C
      select_background = 0x3C3C3C
      normal_color = 0xFFFFFF
      select_color = 0xFFFFFF

      //apply the style to all fields

      function format_field(f)
      for(var a in f)
      f[a].border = true
      f[a].borderColor = normal_border
      f[a].background = true
      f[a].backgroundColor = normal_background
      f[a].textColor = normal_color
      format_field([name_txt,email_txt,business_txt,country_txt,messag e_txt]);

      //define style change function for TXT

      TextField.prototype.onSetFocus = function()
      this.borderColor = select_border
      this.backgroundColor = select_background
      this.textColor = select_color
      TextField.prototype.onKillFocus = function()
      this.borderColor = normal_border
      this.backgroundColor = normal_background
      this.textColor = normal_color
      //set focus

      Any help would be appreciated.