| Package | com.soma.model |
| Class | public class StyleManager |
Author: Romuald Quantin - www.soundstep.com
Information:
Blog page - SomaUI
How does it work - Soma Protest
Project Host - Google Code
Documentation - Soma ASDOC
Class version: 2.0
Actionscript version: 3.0
Copyright:
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied.
See the License for the specific language governing rights and
limitations under the License.
The Original Code is Soma.
The Initial Developer of the Original Code is Romuald Quantin.
Initial Developer are Copyright (C) 2008-2009 Soundstep. All Rights Reserved.
Usage:
The StyleManager handles external stylesheets (css) and gives you an easy access to the styles.
The global stylesheet manager is accessible using:
Soma.getInstance().styles
Soma.getInstance().registerGloBalStyleSheet("styles.css");
Soma.getInstance().addEventListener(StyleSheetEvent.LOADED, eventHandler);
Soma.getInstance().loadStyleSheet("myStyleSheetID", "css/custom.css");
See also
| Method | Defined by | ||
|---|---|---|---|
|
Creates an StyleManager instance
| StyleManager | ||
|
addStyleSheet(id:String, stylesheet:StyleSheet):void
Add a stylesheet to the StyleManager instance and register it with an id.
| StyleManager | ||
|
cloneStyleSheet(target:StyleSheet):StyleSheet
| StyleManager | ||
|
getColor(style:String, stylesheet:StyleSheet = null):uint
Get a color from a stylesheet (the global stylesheet will be used if you don't pass any).
| StyleManager | ||
|
getGlobalStyle(style:String):Object
Get a style from the global stylesheet.
| StyleManager | ||
|
getGlobalStyleSheet():StyleSheet
Get the global stylesheet instance registered (used by default with SomaText instances when a stylesheet is not specified).
| StyleManager | ||
|
getStyle(style:String, stylesheet:StyleSheet = null):Object
Get a style from a stylesheet (the global stylesheet will be used if you don't pass any).
| StyleManager | ||
|
getStyleSheet(stylesheetID:String):StyleSheet
Get a stylesheet using its id.
| StyleManager | ||
|
getStyleSheetID(stylesheet:StyleSheet):String
Get the id of a stylesheet.
| StyleManager | ||
|
getTextFormat(style:String, stylesheet:StyleSheet = null):TextFormat
Get a color from a stylesheet (the global stylesheet will be used if you don't pass any).
| StyleManager | ||
|
loadStyleSheet(id:String, url:String):void
Load a stylesheet and register it with an id.
| StyleManager | ||
|
removeStyleSheet(stylesheetID:String):void
Remove a styleheet from the StyleManager instance using its id.
| StyleManager | ||
|
setGlobalStyleSheet(stylesheet:StyleSheet):void
Set a stylesheet to be the "global stylesheet" (used by default with SomaText instances when a stylesheet is not specified).
| StyleManager | ||
| Constant | Defined by | ||
|---|---|---|---|
| GLOBAL_STYLESHEET_ID : String = "global" [static] id String of the global stylesheet.
| StyleManager | ||
| StyleManager | () | constructor |
public function StyleManager()Creates an StyleManager instance
| addStyleSheet | () | method |
public function addStyleSheet(id:String, stylesheet:StyleSheet):voidAdd a stylesheet to the StyleManager instance and register it with an id.
Parametersid:String — id of the stylesheet.
|
|
stylesheet:StyleSheet — A StyleSheet.
|
| cloneStyleSheet | () | method |
public function cloneStyleSheet(target:StyleSheet):StyleSheetParameters
target:StyleSheet |
StyleSheet |
| getColor | () | method |
public function getColor(style:String, stylesheet:StyleSheet = null):uintGet a color from a stylesheet (the global stylesheet will be used if you don't pass any).
var color:uint = Soma.getInstance().styles.getColor(".myStyle");
trace(color.toString(16));
style:String — Name of the style.
|
|
stylesheet:StyleSheet (default = null) — StyleSheet instance.
|
uint — A uint value (color value).
|
| getGlobalStyle | () | method |
public function getGlobalStyle(style:String):ObjectGet a style from the global stylesheet.
var obj:Object = Soma.getInstance().styles.getGlobalStyle(".myStyle");
for (var i:String in obj) {
trace(i, obj[i])
}
style:String — Name of the style.
|
Object — An object.
|
| getGlobalStyleSheet | () | method |
public function getGlobalStyleSheet():StyleSheetGet the global stylesheet instance registered (used by default with SomaText instances when a stylesheet is not specified).
ReturnsStyleSheet — A StyleSheet instance.
|
| getStyle | () | method |
public function getStyle(style:String, stylesheet:StyleSheet = null):ObjectGet a style from a stylesheet (the global stylesheet will be used if you don't pass any).
var obj:Object = Soma.getInstance().styles.getStyle(".myStyle", myStyleSheet);
for (var i:String in obj) {
trace(i, obj[i])
}
style:String — Name of the style.
|
|
stylesheet:StyleSheet (default = null) |
Object — An object.
|
| getStyleSheet | () | method |
public function getStyleSheet(stylesheetID:String):StyleSheetGet a stylesheet using its id.
ParametersstylesheetID:String — id of the stylesheet.
|
StyleSheet — A StyleSheet instance.
|
| getStyleSheetID | () | method |
public function getStyleSheetID(stylesheet:StyleSheet):StringGet the id of a stylesheet.
Parametersstylesheet:StyleSheet — A StyleSheet instance.
|
String — A String.
|
| getTextFormat | () | method |
public function getTextFormat(style:String, stylesheet:StyleSheet = null):TextFormatGet a color from a stylesheet (the global stylesheet will be used if you don't pass any).
var tf:TextFormat = Soma.getInstance().styles.getTextFormat(".body");style:String — Name of the style.
|
|
stylesheet:StyleSheet (default = null) — StyleSheet instance.
|
TextFormat — A TextFormat instance.
|
| loadStyleSheet | () | method |
public function loadStyleSheet(id:String, url:String):voidLoad a stylesheet and register it with an id.
Parametersid:String — id of the stylesheet.
|
|
url:String — URL of the css file.
|
| removeStyleSheet | () | method |
public function removeStyleSheet(stylesheetID:String):voidRemove a styleheet from the StyleManager instance using its id.
ParametersstylesheetID:String — id of the stylesheet.
|
| setGlobalStyleSheet | () | method |
public function setGlobalStyleSheet(stylesheet:StyleSheet):voidSet a stylesheet to be the "global stylesheet" (used by default with SomaText instances when a stylesheet is not specified).
Parametersstylesheet:StyleSheet — A StyleSheet instance.
|
| GLOBAL_STYLESHEET_ID | constant |
public static const GLOBAL_STYLESHEET_ID:String = "global"id String of the global stylesheet.