PDA

View Full Version : AS3 external CSS and HTML problem...


tomdoes
11-19-2008, 01:07 PM
Hi all,

Still a bit of a newby to AS3 and am having a bit of a mare when I am trying to load html (that is kept in a separate .html file) which is formatted by a stylesheet (which is another separate .css file) into a dynamic text field.

I can get the HTML to load fine, but can not manage to format it with the css!?

I thought it might just be some minor error in that it wasn't finding the file on my computer, so uploaded the files to a server but still the same problem!

I have attached a folder with all the files in...

Please can someone help, it is very frustrating!

tomdoes
11-19-2008, 06:01 PM
please, if anyone can help I would really really appreciate it!!!!

creatify
11-19-2008, 06:24 PM
you have a typo: "kcstyle.cs"

and I set your textField to handle device fonts and last, since you're using span tags with class attributes, you needed a syntax edit to your css:

.TITLE
.BODY

tomdoes
11-19-2008, 06:30 PM
I have been double checking my code and I missed out the second 's' when referencing the CSS file. I have fixed this and am still getting the same problem :(

This is the code I am using...

stop();

var newsload:URLLoader = new URLLoader();
newsload.load(new URLRequest("news.html"));
newsload.addEventListener(Event.COMPLETE, newsloadOK);

function newsloadOK(e:Event):void {
newsTEXT_txt.htmlText = newsload.data;
}

var css:StyleSheet = new StyleSheet();

var cssLoader:URLLoader = new URLLoader();
cssLoader.load(new URLRequest("kcstyle.css"));
cssLoader.addEventListener(Event.COMPLETE, cssLoadComplete);

function cssLoadComplete(e:Event):void {
css.parseCSS(cssLoader.data);
newsTEXT_txt.styleSheet = css;
newsTEXT_txt.htmlText = newsload.data;
}


this.newsUP_btn.addEventListener(MouseEvent.CLICK, scrollup);
function scrollup(myevent:MouseEvent):void {
newsTEXT_txt.scrollV--;
}

this.newsDOWN_btn.addEventListener(MouseEvent.CLIC K, scrolldown);
function scrolldown(myevent:MouseEvent):void {
newsTEXT_txt.scrollV++;
}

tomdoes
11-19-2008, 06:33 PM
Creatify,

I posted the last message at the same time as your post. Thank you very much for the help! It works perfectly, I didn't know about having to use syntax like that in my CSS. Very thankful!!

creatify
11-19-2008, 06:34 PM
look at the files I attached on the last post. I changed css, and actionscript I set the AS so your css loads first, then your news loads - the version I posted is working.

EDIT:
cool deal, glad to help.