This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Flash Site Design > June 2005 > Error Loading Stylesheet
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Error Loading Stylesheet
|
|
| paulpsd7 2005-06-17, 11:20 pm |
| I'm trying to load an external stylessheet which I'll use to style a column of
text in a FLA. I've grabbed two pieces of code from the online help, and
neither works.
Here's one:
var styles = new TextField.StyleSheet ();
TextField.styles.load("abbott.css");
TextField.styles.onLoad = function (ok) {
if (ok) {
trace (this.getStyleNames());
trace ("CSS file loaded");
} else {
trace ("Error loading CSS file");
}
}
Here's the other:
var my_styleSheet:TextField.StyleSheet = new TextField.StyleSheet();
my_styleSheet.onLoad = function(success:Boolean) {
if (success) {
trace("Styles loaded:");
var styles_array:Array = my_styleSheet.getStyleNames();
trace(styles_array.join(newline));
} else {
trace("Error loading CSS");
}
};
my_styleSheet.load("abbott.css");
Both of these functions return "Error loading CSS". I have ensured that
"abbott.css" is spelled correctly, and that the file is in the same directory
as the SWF file. What is wrong?
| |
| merlinvicki 2005-06-18, 7:18 pm |
| Hi paul
I've alredy answered your question in your another thread. Check that one . You will probably find what you are looking for.
:)
| |
| paulpsd7 2005-06-24, 4:25 am |
| Thanks, merlinvicki. Your example is great. It enabled me to trudge one more
step along.
I've modified your code and tried to bring in my own content. My own content
did come in, but the stylesheet still won't. Here's my code:
var ss:TextField.StyleSheet = new TextField.StyleSheet();
ss.load("abbott.css");
content.styleSheet = ss;
trace (this.getStyleNames());
content.multiline= true;
content.wordWrap = true;
content.html = true;
function loadChapter (chapter) {
story = new XML();
story.ignoreWhite = true;
story.load(chapter);
story.onLoad = function () {
content.htmlText = story;
}
}
I put your actionscript into a function that I can call, specifying which
chapter to load. This much works. My text gets imported and displayed. However,
the text has no formatting except for the default formatting set in my FLA
(Verdana, white, 14pt). The trace command returns undefined. Also, the text
appearing in the box doesn't wrap, despite setting wordWrap to true. There's no
question that the file abbott.css is located in the same folder as the FLA and
exported SWF. I also put your sample.css file in there too, and changed the
reference in the actionscript, but it wouldn't import that either.
| |
| merlinvicki 2005-06-24, 7:20 am |
| Can I have a look at ur FLA. There must be a very small thing u may be mising.
Check the movieclips instance name, instance name of the textbox, most of the time the problem lies in these areas.
| |
| merlinvicki 2005-06-25, 11:14 pm |
| Change ur first frame code to this:
__________________________________________________________
_global.loadChapter = function(chapter) {
var ss:TextField.StyleSheet = new TextField.StyleSheet();
ss.load("abbott.css");
content.styleSheet = ss;
content.multiline = true;
content.wordWrap = true;
content.html = true;
story = new XML();
story.ignoreWhite = true;
story.load(chapter);
story.onLoad = function() {
content.htmlText = story;
};
};
________________________________________________________________
and call it via:
loadChapter("chapter1.htm")
There also seems to be some problem with your CSS cause it was working with
the sample.css I provided earlier.
Here is the css code for abbott.css try modifying the code with this css to
get ur required results.
h1 {
font-family: Arial,Helvetica,sans-serif;
font-size: 16px;
font-weight: bold;
display: block;
color:#000000;
}
subheadline {
font-family: Arial,Helvetica,sans-serif;
font-size: 13px;
font-weight: bold;
display: block;
color:#000000;
}
body_text {
font-family: Arial,Helvetica,sans-serif;
font-size: 10px;
display: block;
color:#000000;
}
biline {
font-family: Arial,Helvetica,sans-serif;
font-size: 11px;
font-style: italic;
display: inline;
color:#000000;
}
A {
font-family: Arial,Helvetica,sans-serif;
color:cccccc;
font-size: 10px;
display: inline;
text-decoration:underline;
color:#000000;
}
Any problems get the file here:
http://www.merlinvicki.com/samples/chapter1.zip
keep flashing!
| |
| paulpsd7 2005-06-27, 7:42 pm |
| YES!!! It worked!
The problem seems have been caused by the fact that the stylesheet was
imported separately from the text. Once I combined both imports into the same
function, it worked! Merlinvicki, you are a star!!! Thank you so much.
| |
| merlinvicki 2005-06-28, 4:16 am |
| :D
cool. keep in touch
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|