Skip to main content
Inspiring
April 16, 2008
Answered

not sure why my external CSS file will not load

  • April 16, 2008
  • 8 replies
  • 867 views
using this for the AS

var styles:TextField.StyleSheet = new TextField.StyleSheet();
styles.onLoad = function(success:Boolean):Void {
if (success) {
//display style names
trace(this.getStyleNames());
} else {
trace("Error loading CSS file.");
}
};
styles.load("styles.css");

I have a CSS file in the same folder called styles.css

for some reason though I only get the message

"Error loading CSS file"

I don't believe there are any errors in my script, but I could be wrong. A second pair of eyes will help!
This topic has been closed for replies.
Correct answer DPSwebmaster
doh! thanks. DW had placed that in there, and I neglected to take it out.

works fine now

8 replies

kglad
Community Expert
Community Expert
April 18, 2008
you're welcome.
kglad
Community Expert
Community Expert
April 18, 2008
css files don't have headers. remove those.
DPSwebmasterAuthorCorrect answer
Inspiring
April 18, 2008
doh! thanks. DW had placed that in there, and I neglected to take it out.

works fine now
kglad
Community Expert
Community Expert
April 17, 2008
your code is fine.
Inspiring
April 18, 2008
I have a zip file of my .fla and .css files. They can be downloaded from www.inspired-evolution.com/LoadStyles.zip

if anyone has time to download and take a look, I would be greatly appreciative.
kglad
Community Expert
Community Expert
April 16, 2008
so, you're testing from the test environment? if yes, post a link to your zipped css file and fla.
Inspiring
April 17, 2008
actually I am just testing locally for now. Does it matter that I am using AS2 code with Flash CS3? Can someone else create a small css file real quick and try out the code to see fi it works for them?
kglad
Community Expert
Community Expert
April 16, 2008
where's you html file?
Inspiring
April 16, 2008
don't have an HTML file
Inspiring
April 16, 2008
Are you sure the css is a properly saved text file? Not some kind of RTF or doc or something that just has a css ending?

The best I've usually found is to save files at UTF-8.

After you get the error message (I assume you are in the testing environment) go up to the debug menu and select List Variables. Do you see anything in your Stylesheet?
kglad
Community Expert
Community Expert
April 16, 2008
same directory as what?
Inspiring
April 16, 2008
as the fla. and swf files. Everything is at the same level, I am testing from my desktop.
kglad
Community Expert
Community Expert
April 16, 2008
there's no script problem so your styles.css has a typo or isn't in the same directory with your swf's embedding html file.
Inspiring
April 16, 2008
I have double and triple checked and the style is named the same and in the same directory, so I am not sure what else I can do...