How to load and apply CSS stylesheet at runtime in a Flex application?

I would like to download CSS stylesheets from a URL and apply them to my Flex 3 application at runtime. Is it possible?

+3
source share
2 answers

You cannot load an uncompiled CSS file into your Flex application at run time. You must compile it in SWF before downloading. - Adobe Flex 3 documents

You can load stylesheets (compiled) using the Style Manager.

For a complete run: Loading style sheets at runtime

+2
source

css , TextField.

var loader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest("style.css");
loader.load(req);
loader.addEventListener(Event.COMPLETE, completeHandler);

private function completeHandler(e:Event):void 
{
  var css:StyleSheet = new StyleSheet();
  css.parseCSS(e.target.data);
  yourTextField.styleSheet = css;
}

, , . , StyleSheet - styleNames array getStyle.

+3

Source: https://habr.com/ru/post/1747125/


All Articles