Packagecom.rubenswieringa
Classpublic class CSSLoader
InheritanceCSSLoader Inheritance flash.events.EventDispatcher

Enables runtime loading of css files in Actionscript 3.0

See also

CSSParser.html


Public Properties
 PropertyDefined by
  lastLoadedName : String
[read-only] The name of the last loaded stylesheet.
CSSLoader
Public Methods
 MethodDefined by
  
Constructor.
CSSLoader
  
applyLastLoadedStyle(displayObj:DisplayObject, applyToChildren:Boolean = false):void
Applies the last loaded stylesheet to the specified DisplayObject.
CSSLoader
  
applyStyle(css:String, displayObj:*, applyToChildren:Boolean = false):void
Applies the specified stylesheet to the specified DisplayObject.
CSSLoader
  
Enlists all stylesheets (both loaded and still loading).
CSSLoader
  
getHTMLStyleSheet(css:String):StyleSheet
Returns a StyleSheet instance containing all the style declarations from the specified stylesheet.
CSSLoader
  
load(url:String, name:String = "", ... args):void
Loads a css file.
CSSLoader
  
loadString(raw:String, name:String, ... args):void
Similar to the load function, the difference being that loadString takes the String content, where load takes a String URL.
CSSLoader
  
removeStyle(name:String):Boolean
Removes the specified stylesheet (must have finished loading!).
CSSLoader
Events
 EventSummaryDefined by
   Dispatched when a CSS file is loaded succesfully.CSSLoader
   Dispatched when there was an error while trying to load a CSS file.CSSLoader
   Dispatched when CSSLoader starts loading a CSS file.CSSLoader
   Dispatched when a parsing error occurs within CSSParser.CSSLoader
Public Constants
 ConstantDefined by
  FAULT : String = "onCSSFault"
[static]
CSSLoader
  LOAD_INIT : String = "onCSSLoadInit"
[static]
CSSLoader
  RESULT : String = "onCSSLoaded"
[static]
CSSLoader
Property detail
lastLoadedNameproperty
lastLoadedName:String  [read-only]

The name of the last loaded stylesheet.

Implementation
    public function get lastLoadedName():String
Constructor detail
CSSLoader()constructor
public function CSSLoader()

Constructor.

Method detail
applyLastLoadedStyle()method
public function applyLastLoadedStyle(displayObj:DisplayObject, applyToChildren:Boolean = false):void

Applies the last loaded stylesheet to the specified DisplayObject.

Parameters
displayObj:DisplayObject — the DisplayObject to which to apply the stylesheet
 
applyToChildren:Boolean (default = false) — whether or not to apply the stylesheet to the DisplayObject's children (if any) [optional]

See also

applyStyle()method 
public function applyStyle(css:String, displayObj:*, applyToChildren:Boolean = false):void

Applies the specified stylesheet to the specified DisplayObject.

Parameters
css:String — the name of the stylesheet (must have finished loading!)
 
displayObj:* — the DisplayObject to which to apply the stylesheet
 
applyToChildren:Boolean (default = false) — whether or not to apply the stylesheet to the DisplayObject's children (if any) [optional]
getAllStyleNames()method 
public function getAllStyleNames():Array

Enlists all stylesheets (both loaded and still loading).

Returns
Array — an Array with the names of all stylesheets
getHTMLStyleSheet()method 
public function getHTMLStyleSheet(css:String):StyleSheet

Returns a StyleSheet instance containing all the style declarations from the specified stylesheet.

Parameters
css:String — Name identifier of a loaded stylesheet

Returns
StyleSheet — StyleSheet
load()method 
public function load(url:String, name:String = "", ... args):void

Loads a css file.

Parameters
url:String — path of the css file
 
name:String (default = "") — name for the stylesheet within the class [optional]
 
... args — DisplayObject(s) to apply the loaded stylesheet to, note that the stylesheet will also be applied to the DisplayObjects' their children (use the RESULT event and applyStyle method if this is not what you want)
loadString()method 
public function loadString(raw:String, name:String, ... args):void

Similar to the load function, the difference being that loadString takes the String content, where load takes a String URL.

Parameters
raw:String — the plain text stylesheet from a css file
 
name:String — name for the stylesheet within the class [optional]
 
... args — DisplayObject(s) to apply the loaded stylesheet to, note that the stylesheet will also be applied to the DisplayObjects' their children

See also

removeStyle()method 
public function removeStyle(name:String):Boolean

Removes the specified stylesheet (must have finished loading!).

Parameters
name:String — the name of the stylesheet to be removed

Returns
Boolean — whether or not the specified stylesheet was found
Event detail
loadedevent 
Event object type: mx.events.Event

Dispatched when a CSS file is loaded succesfully.

load faultevent  
Event object type: mx.events.Event

Dispatched when there was an error while trying to load a CSS file.

load initevent  
Event object type: mx.events.Event

Dispatched when CSSLoader starts loading a CSS file.

parse errorevent  
Event object type: mx.events.Event

Dispatched when a parsing error occurs within CSSParser.

See also

Constant detail
FAULTconstant
public static const FAULT:String = "onCSSFault"
LOAD_INITconstant 
public static const LOAD_INIT:String = "onCSSLoadInit"
RESULTconstant 
public static const RESULT:String = "onCSSLoaded"