/** * VERSION: 1.84 * DATE: 2011-03-23 * AS3 * UPDATES AND DOCS AT: http://www.greensock.com/loadermax/ **/ package com.greensock.loading { import flash.events.Event; import flash.text.StyleSheet; /** Dispatched when the loader's httpStatus value changes. **/ [Event(name="httpStatus", type="com.greensock.events.LoaderEvent")] /** * Loads StyleSheet (CSS) data.

* * OPTIONAL VARS PROPERTIES
* The following special properties can be passed into the CSSLoader constructor via its vars * parameter which can be either a generic object or a CSSLoaderVars object:
*
* * Note: Using a CSSLoaderVars instance * instead of a generic object to define your vars is a bit more verbose but provides * code hinting and improved debugging because it enforces strict data typing. Use whichever one you prefer.

* * content data type: flash.text.StyleSheet

* * @example Example AS3 code: import com.greensock.loading.~~; import com.greensock.events.LoaderEvent; import import flash.text.StyleSheet; //create a CSSLoader var loader:CSSLoader = new CSSLoader("css/styles.css", {name:"myCSS", requireWithRoot:this.root, estimatedBytes:900}); //begin loading loader.load(); //Or you could put the CSSLoader into a LoaderMax. Create one first... var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); //append the CSSLoader and several other loaders queue.append( loader ); queue.append( new SWFLoader("swf/main.swf", {name:"mainSWF", estimatedBytes:4800}) ); queue.append( new ImageLoader("img/photo1.jpg", {name:"photo1", estimatedBytes:3500}) ); //start loading queue.load(); function progressHandler(event:LoaderEvent):void { trace("progress: " + event.target.progress); } function completeHandler(event:LoaderEvent):void { myTextField.styleSheet = LoaderMax.getContent("myCSS"); trace("load complete."); } function errorHandler(event:LoaderEvent):void { trace("error occured with " + event.target + ": " + event.text); } * * Copyright 2011, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership. * * @see com.greensock.loading.data.CSSLoaderVars * * @author Jack Doyle, jack@greensock.com */ public class CSSLoader extends DataLoader { /** @private **/ private static var _classActivated:Boolean = _activateClass("CSSLoader", CSSLoader, "css"); /** * Constructor * * @param urlOrRequest The url (String) or URLRequest from which the loader should get its content. * @param vars An object containing optional configuration details. For example: new CSSLoader("css/styles.css", {name:"myCSS", onComplete:completeHandler, onProgress:progressHandler}).

* * The following special properties can be passed into the constructor via the vars parameter * which can be either a generic object or a CSSLoaderVars object:
* * @see com.greensock.loading.data.CSSLoaderVars */ public function CSSLoader(urlOrRequest:*, vars:Object=null) { super(urlOrRequest, vars); _loader.dataFormat = "text"; //just to make sure it wasn't overridden if the "format" special vars property was passed into in DataLoader's constructor. _type = "CSSLoader"; } //---- EVENT HANDLERS ------------------------------------------------------------------------------------ /** @private **/ override protected function _receiveDataHandler(event:Event):void { var style:StyleSheet = _content = new StyleSheet(); style.parseCSS(_loader.data); super._completeHandler(event); } } }