I used to read an article about ultrashock. Article , So I wrote a class, which makes it much easier to use.
/*************************************** * ** Cssstyle * References an external style sheet to the component * eg: * var cssstyle: cssstyle = new cssstyle ("style.css"); * apply the style to _ root. mycombox object * cssstyle. applyto (_ root. mycombox, "combox"); * apply the style to all ComboBox objects * cssstyle. applyto (_ global. styles. comboBox, "combox"); * apply the style to all components * cssstyle. applyto (_ global. style, "combox "); * *****************************/class cssstyle {// style table path Private VaR Csspath: String ; Private VaR Isloaded: Boolean = False ; Private VaR Cssresult; Public Function Cssstyle (_ csspath:String ){ This . Csspath = _ csspath; This . Incircle ();} // applyto method // _ component: component or Mc object to apply the style // _ style: style name of the application Public Function Applyto (_ component: Object , _ Style: String ): Void { VaR Component: Object = _ Component; VaR Style: String = _ Style; VaR SELF: Object = This ; If (Self.css result = Undefined ){ VaR Cssdata: Loadvars = New Loadvars (); Cssdata. Load ( This . Csspath); cssdata. ondata = Function (Raw) {self.css result = New Textfield . Stylesheet (); self.css result. parsecss (raw); self. applycss (component, self.css result. _ CSS [style]);} Else {Self. applycss (component, self.css result. _ CSS [style]) ;}// apply the style sheet content to the specified component. Private Function Applytocomponent (targetobj: Object , Styleobj: Object ){ For ( VaR I In Styleobj ){ If (Styleobj [I]. substr (0, 1) = "#") {styleobj [I] = "0x" + styleobj [I]. substr (1);} targetobj. setstyle (I, styleobj [I]) ;}// pass the style sheet component and object to the application function Private Function Applycss (COMP, cssobj) {applytocomponent (COMP, cssobj);} // Initialization Private Function Inode (): void { VaR SELF: Object = This ; VaR Cssdata: Loadvars = New Loadvars (); Cssdata. Load ( This . Csspath); cssdata. ondata = Function (Raw) {self.css result = New Textfield . Stylesheet (); self.css result. parsecss (raw );};}}