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.
//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:
//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:
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