# Error when adding style to textfield

**URL:** <https://forum.kirupa.com/t/error-when-adding-style-to-textfield/263709>\
**Category:** Uncategorized\
**Created:** [June 18, 2008, 3:06pm UTC](https://forum.kirupa.com/t/error-when-adding-style-to-textfield/263709 "2008-06-18T15:06:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![uberalles](https://avatars.discourse-cdn.com/v4/letter/u/e47774/32.png) [@uberalles](https://forum.kirupa.com/u/uberalles)\
**Post date:** [June 18, 2008, 3:06pm UTC](https://forum.kirupa.com/t/error-when-adding-style-to-textfield/263709/1 "2008-06-18T15:06:50Z")

</div>

I’m trying to add a stylesheet to a textfield and I keep getting this error:

```auto

1119: Access of possibly undefined property styleSheet through a reference with static type fl.controls:TextInput. 

```

here is the code in question (chatarea is the textfield obviously):

```auto

var style:StyleSheet = new StyleSheet();
            var heading:Object = new Object();
            heading.fontWeight = "bold";
            heading.color = "#FF0000";
            var body:Object = new Object();
            body.fontStyle = "italic";
            style.setStyle(".h1", heading);
            style.setStyle("body", body);
chatarea.styleSheet = style;

```

I get the error on “chatarea.styleSheet = style;”. Anyone know what’s causing this?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Alex\_Lexcuk](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Alex\_Lexcuk](https://forum.kirupa.com/u/Alex_Lexcuk)\
**Post date:** [June 18, 2008, 5:24pm UTC](https://forum.kirupa.com/t/error-when-adding-style-to-textfield/263709/2 "2008-06-18T17:24:49Z")

</div>

unknown, but

```auto

var style:StyleSheet = new StyleSheet();
var styleA:Object = new Object();
var styleA_linc:Object = new Object();
var style_div:Object = new Object();
style_div.color="#220000";
style_div.textAlign="center";
styleA_linc.color="#220000";
styleA.color = "#FF0000";
styleA_linc.fontWeight = "bold";
//styleA.fontStyle = "italic";
style.setStyle("h1", style_div);
styleA.textDecoration="underline";
style.setStyle("a", styleA);
style.setStyle("a:hover", styleA_linc);

my_txt.styleSheet=style;

```

[http://dnadillo.dn.ua/fla/XML/img-xml.swf](http://dnadillo.dn.ua/fla/XML/img-xml.swf)  
[http://dnadillo.dn.ua/fla/XML/mur\_xml\_file\_img.xml](http://dnadillo.dn.ua/fla/XML/mur_xml_file_img.xml)
