Using an external CSS file to style a Flash MX 2004
/* Styles ( external ) */
Window{
backgroundColor:0xFF0000;
}
ComboBox{
backgroundColor:0xFF0000;
}
var objStyleSheet:TextField.StyleSheet = new TextField.StyleSheet();
var arrStyles:Array;
var objComponent:Object;
var objStyle:Object;
objStyleSheet.onLoad = function (booSuccess:Boolean):Void{
if(booSuccess){
trace("NOTICE: GamesBase Stylesheet loaded successfully.");
arrStyles = objStyleSheet.getStyleNames();
for(var i in arrStyles){
// Get the components global style.
objComponent = eval("_global.styles." + arrStyles[i]);
// Get the style object containing the style attributes.
objStyle = this.getStyle(arrStyles[i]);
// If there is no stylesheet, make one.
if(objComponent == undefined){
objComponent = new mx.styles.CSSStyleDeclaration();
}
// Loop through and apply the attributes to the gloabl style for the given component.
for(var z in objStyle){
objComponent.setStyle(z, objStyle[z]);
}
}
}else{
trace("The style sheet failed to laod!");
}
// Dont need this function anymore.
objStyleSheet.onLoad = undefined;
}
// Load the stylesheet.
objStyleSheet.load(GamesBase.objConfigData["styleSheet"]);
|