# I need help applying CSS in AS3

**URL:** <https://forum.kirupa.com/t/i-need-help-applying-css-in-as3/326251>\
**Category:** flash\
**Created:** [December 1, 2011, 7:16pm UTC](https://forum.kirupa.com/t/i-need-help-applying-css-in-as3/326251 "2011-12-01T19:16:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![m2244](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@m2244](https://forum.kirupa.com/u/m2244)\
**Post date:** [December 1, 2011, 7:16pm UTC](https://forum.kirupa.com/t/i-need-help-applying-css-in-as3/326251/1 "2011-12-01T19:16:03Z")

</div>

Hello,

I have Googled this all afternoon. How do you apply a style in AS3? I need to apply them to movieclips and hopefully a textArea.

Thanks for the look.

The CSS

```auto

swfStyle{
font-family: Arial;
font-size: 12px;
text-align:center;
color:#FF0000;
}

```

The AS3

```auto

/ *********Load the CSS file.****************************** /
var loadCSSFile:String = "styles/new_pup.css";// Get the URL for the HTML file
var loadedCSSFile:String;// Variable to store the HTML data
var loader2:URLLoader = new URLLoader();
loader2.addEventListener(Event.COMPLETE, handleCSSLoad);
loader2.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
loader2.load(new URLRequest(loadCSSFile));

function handleCSSLoad(evt:Event):void
{
	//mcPopup.txtContent.htmlText = "In the handleCSSLoad function";
	
	loader2.removeEventListener(Event.COMPLETE, handleCSSLoad);
	var cssStyle:StyleSheet = new StyleSheet();
	cssStyle.parseCSS(evt.target.data);
	//txtTitle.styleSheet = cssStyle;
	//mcPopup.txtContent.styleSheet = cssStyle;
	style = cssStyle.getStyle("swfStyle");
		
	loader.load(new URLRequest(loadHTMLFile));
}

```
