# Learning CSS in Flash

**URL:** <https://forum.kirupa.com/t/learning-css-in-flash/175547>\
**Category:** flash\
**Created:** [January 15, 2006, 6:01pm UTC](https://forum.kirupa.com/t/learning-css-in-flash/175547 "2006-01-15T18:01:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CayoHueso](https://avatars.discourse-cdn.com/v4/letter/c/8e8cbc/32.png) [@CayoHueso](https://forum.kirupa.com/u/CayoHueso)\
**Post date:** [January 15, 2006, 6:01pm UTC](https://forum.kirupa.com/t/learning-css-in-flash/175547/1 "2006-01-15T18:01:05Z")

</div>

Hi everybody,

I am learning how to use CSS in Flash, and I am having a problem. I have this first code to create two functions. The first one to load a txt file, the second one to load a CSS file.

```auto

//function to load text
function loadMyText (textURL:String) {
    var loadit_lv:LoadVars = new LoadVars ();
    loadit_lv.load (textURL);
    loadit_lv.onLoad = function (success:Boolean) {
        if (success) {
            my_txt.text = this.content;
        } else {
            trace ("Could not load text file.");
        }
    };
}
//function to apply stylesheet
var flash_css = new TextField.StyleSheet ();
function loadMyCSS (cssURL:String) {
    flash_css.load (cssURL);
    flash_css.onLoad = function (success:Boolean) {
        if (success) {
            my_txt.styleSheet = flash_css;
        } else {
            trace ("Could not load CSS file.");
        }
    };
}

```

Then I have the following two lines:

```auto

//loads the text
loadMyText ("experience.txt");
//loads the first css
loadMyCSS ("styles1.css");

```

Until here everything works great.

Then I try to load a different text in the same textField, and apply the same CSS:

```auto

text2_btn.onPress = function () {
    loadMyText ("text2.txt");
    loadMyCSS ("styles1.css");
};

```

When I press the button text2\_btn, the text is loaded, but it does not display with the CSS properties.

Could anyone help me with this, please?  
Thanks a lot
