Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-03-2012, 02:09 AM   PM User | #1
tommyzDad
New to the CF scene

 
Join Date: Jun 2012
Location: Manassas, Virginia
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
tommyzDad is an unknown quantity at this point
External CSS Styling Not Being Applied

I've a manually created text field, newsText_tf, into which I am able to load text. The text file, "writeUp1.txt", is definitely getting loaded, but the CSS styling found in "newsStyle.css" in not getting applied, or loaded at all.

I slipped in a few trace commands and supposed the CSS is getting loaded, or at least the function in which the trace code is found is getting read.

Anyway, here's the code:

Code:
import flash.events.Event;
import flash.net.URLLoader;
var navBanNews:URLRequest = new URLRequest("content_news/writeUp1.txt");
var newsLoader:URLLoader = new URLLoader(navBanNews);
var cssLoader:URLLoader = new URLLoader();

//Load the text file ("writeUp1.txt")
newsLoader.addEventListener(Event.COMPLETE, newsLoadCompleted);
function newsLoadCompleted(event:Event):void
{
	var newsLoaded:URLLoader = URLLoader(event.target);
	newsBox_mc.newsText_tf.htmlText = newsLoaded.data;
	callCss();
		trace("Text loaded!");
}

//Load the CSS file ("newsStyle.css")
function callCss():void
{
	var newsStyleRequest:URLRequest = new URLRequest("content_news/newsStyle.css");
	cssLoader.addEventListener(Event.COMPLETE, cssLoadComplete);
	cssLoader.load(newsStyleRequest);
		trace("CSS loaded!");
}

function cssLoadComplete(event:Event):void
{
	
	var newsStyle:StyleSheet = new StyleSheet();
	newsStyle.parseCSS(cssLoader.data);
	newsBox_mc.newsText_tf.styleSheet = newsStyle;
	newsBox_mc.newsText_tf.wordWrap = true;
	newsBox_mc.newsScroller.update();
		trace("CSS load complete!");
}
I don't know if it means anything, but when I Test the movie, the "CSS loaded" trace is displayed first in the Output panel.

Last edited by tommyzDad; 07-03-2012 at 07:51 PM..
tommyzDad is offline   Reply With Quote
Old 07-04-2012, 01:50 AM   PM User | #2
tommyzDad
New to the CF scene

 
Join Date: Jun 2012
Location: Manassas, Virginia
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
tommyzDad is an unknown quantity at this point
Thumbs up Solved

Problem solved!!!!!

Select TLF Text in the Properties panel, when you have your text field selected!!

Last edited by tommyzDad; 07-05-2012 at 05:46 PM..
tommyzDad is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:34 AM.


Advertisement
Log in to turn off these ads.