FMX04: Why does CSS work alone but not in app?

Hi all
I think I’m missing something simple and trivial in my coding (AS2), please have a look and come with suggestions to a solution. Thank’s. :slight_smile:

Problem:
When I use the code below it works fine and loads the CSS-file and shows the the html-textarea as it should be CSS-formatted. BUT when I try to put the SAME code into a movieclip within another fla-movie it does not work (loads text but not css) and I get un “undefined” all the time.

After trying a lot of different things I’ve come to the conclusion that it MIGHT have soemthing to do with the .onLoad that gets “undefined” in some way.

As you can see below I’m getting two vars from input textfields and then use a button to activate the function loadCSS().

ActionScript 2 code:

function loadCSS() {
trace(“funktion loadCSS started”)
// Create a new style sheet and LoadVars object
var myVars:LoadVars = new LoadVars();
var styles = new TextField.StyleSheet();

// Location of CSS and text files to load
var txt_url = textUrl.text // “myText.txt”;
var css_url = cssUrl.text // “html_styles.css”;

// Load text to display and define onLoad handler
myVars.load(txt_url);
myVars.onData = function(content) {
storyText = content;
};
// Load CSS file and define onLoad handler:
styles.load(css_url);
styles.onLoad = function(ok) {
if (ok) {
// If the style sheet loaded without error,
// then assign it to the text object,
// and assign the HTML text to the text field.
trace(this.getStyleNames())
news_txt.styleSheet = styles;
news_txt.text = storyText;
trace(“css laddat ok!”)
} else {
// If something whent wrong
news_txt.text = “Error loading css.”
}
}
}
(End of AS2 code)

The css-file (html_styles.css) content:
p {
color: #000000;
font-family: Arial,Helvetica,sans-serif;
font-size: 12px;
display: inline;
}

a:link {
color: #FF0000;
}

a:hover{
text-decoration: underline;
}

.headline {
color: #000000;
font-family: Arial,Helvetica,sans-serif;
font-size: 18px;
font-weight: bold;
display: block;
}

.byline {
color: #666600;
font-style: italic;
font-weight: bold;
display: inline;
}

(End css-file)

The Textfile (myText.txt) content (just some swedish testtext):
<p class=‘headline’>Kolla detta är en headline som funkar!</p><p><span class=‘byline’>En liten byline från Rimbo</span>–Kul att testa och se om detta fungerar som vanlig paragraftext… Undrar om åäöÅÄÖ funkar eller om det bara är fel teckenkodninmg på textfilen? Provar nu med textfilsformatet Unicode UTF-8, kanske det funkar bättre? (Ja det gjorde det :slight_smile:

Detta skall vara början på ett nytt stycke hoppas jag. Om du vill se hur bra länkar blir så kan du prova att “hovra” över denna länk: <a href=‘http://ideplanket.se’>Idéplankets hemsida</a>

Nästa stycke, i css-filen som används så är endast följande definerat; p, a:link, a:hover, .headline, .byline .</p>
(End of textfile)