Hello
It's very simple to apply styles from external css to mxlm custom component: just?drop %26lt;mx:style source=''file.css''%26gt; and it's done.
My question is: how to apply styles from external css (packaged in the same swc) for custom action script component ,say CollapsiblePanel?
Thanks
Applying styles from external css to...Hi,
You can use style manager class to access the style.
collapsiblepanel.styleName = StyleManager.getStyleDeclaration(''.panelheader'');
Applying styles from external css to...The following link and code should answer your question.
If this post answers your question or helps, please mark it as such.
http://livedocs.adobe.com/flex/3/html/help.html?content=Working_with_Text_15.htm l
Next is the ActionScript code for a class that loads the example.css file and applies the styles to TextField content:
package
{
?import flash.display.Sprite;
?import flash.events.Event;
?import flash.net.URLLoader;
?import flash.net.URLRequest;
?import flash.text.StyleSheet;
?import flash.text.TextField;
?import flash.text.TextFieldAutoSize;
?public class CSSFormattingExample extends Sprite
?{
?var loader:URLLoader;
?var field:TextField;
?var exampleText:String = ''%26lt;h1%26gt;This is a headline%26lt;/h1%26gt;'' +
?''%26lt;p%26gt;This is a line of text. %26lt;span class='bluetext'%26gt;'' +
?''This line of text is colored blue.%26lt;/span%26gt;%26lt;/p%26gt;'';
?
?public function CSSFormattingExample():void
?{
?field = new TextField();
?field.width = 300;
?field.autoSize = TextFieldAutoSize.LEFT;
?field.wordWrap = true;
?addChild(field);
?
?var req:URLRequest = new URLRequest(''example.css'');
?
?loader = new URLLoader();
?loader.addEventListener(Event.COMPLETE, onCSSFileLoaded);
?loader.load(req);
?}
?
?public function onCSSFileLoaded(event:Event):void
?{
?var sheet:StyleSheet = new StyleSheet();
?sheet.parseCSS(loader.data);
?field.styleSheet = sheet;
?field.htmlText = exampleText;
?}
?}
}
When the CSS data is loaded, the onCSSFileLoaded() method executes and calls the StyleSheet.parseCSS() method to transfer the style declarations to the StyleSheet object.