CSSLoader
by Ruben
Today I made the last completion to my CSSLoader class, the class enables you to load CSS files into your flex application during runtime, a functionality Actionscript3.0 lacks. It's actually as easy as this:
var loader:CSSLoader = new CSSLoader(); loader.load("mycssfile.css", "nameToBeGiven", displayObj1, displayObj2);
..where the amount of DisplayObjects (to which the style will be applied automatically after loading has finished) is infinite. The style will also automatically be applied to the given DisplayObjects' their children (if any).
Obviously, the class comes with many more features (methods and events), which are all to be found in the docs.
Go check out the demo, and browse through the source and documentation.
Please leave a comment and tell me what you think..
Oh, and big thanks go out to Maikel for helping my out time after time again..
Comments (read newer or show 35 trackbacks)
Trackbacks:
No thanx!! Keep up the good work!
[...] trotste ben ik op de CSSLoader class die ik woensdag gepubliceerd heb. Maikel vertelde me, toen hij zag dat ik javadoc comments in mijn [...]
Does this class load non-css attributes that flex understands, such as selectedUpSkin, etc…?
quote from Eric:
Long answer: Yes it does, basically my class reads key/value pairs from the css-file and applies them through setStyle, so if setStyle() accepts selectedUpSkin (which I’m pretty sure it does) then you can put it in your css-file..
Short answer: Yes.
Nice class. I did have problems when setting URLs for properties like backgroundImage. I changed
protected function parseProperty (property:String):XML {
var pair:Array = property.split(‘:’);
….
to this:
protected function parseProperty (property:String):XML {
var idx:int = property.indexOf(‘:’);
var pair:Array = new Array();
pair.push(property.slice(0, idx));
pair.push(property.slice(idx + 1));
Thanks again for putting the class out there.