views:

20

answers:

2

I'm working in a Flash Builder 4 Actionscript project and trying to figure out how to embed a css file into the project at "compile-time". Just as we did when we use MXML's <fx:Style> tag.

Any idea?

A: 

Quote from the Flex 3 help documentation:

You can specify a CSS file as an argument to the source-pathcompiler argument. This lets you toggle among style sheets with that compiler argument.

hleinone
Thanks. What's the AS3 code for this?
JONYC
If you're willing to do it in the AS3 side, I guess you're then going for applying stylesheets at runtime...
hleinone
A: 
// Embed your stylesheet with the octet-stream mime-type 

[Embed(source="assets/stylesheet.css", mimeType="application/octet-stream")] 
private var stylesCSS:Class;   

public function createStyleSheetObject():StyleSheet 
{
    // create a new StyleSheet instance
    var styleSheet:StyleSheet = new StyleSheet();
    styleSheet.parseCSS(new stylesCSS().toString());
    return styleSheet; 
}
Adrian Pirvulescu