Packagecom.sibirjak.jakute
Classpublic class JCSS_Sprite
InheritanceJCSS_Sprite Inheritance flash.display.Sprite

JCSS enabled base ui class (optional and just for convenience).

Although it is intended to fully decouple Jaktute Styling Engine code from the actual component implementations, the probable cleanest and preferred way to work is to put the style handling in a base ui class, and let all components inherit from that class. Such a class is JCSS_Sprite.

Notes

JCSS_Sprite has nearly the same interface as JCSS_Adapter with the difference, that all properties and methods carry a leading "jcss_" prefix to avoid collision with component code.

A handler for the component registered event is not available. Related code might be added right to the constructor of the subclass, because the constructor itself performs the registraion.



Public Properties
 PropertyDefined by
  jcss : JCSS
[static]
JCSS_Sprite
  jcss_cssClass : String
Sets and returns the component css class.
JCSS_Sprite
  jcss_cssID : String
Sets and returns the component selector ID.
JCSS_Sprite
  jcss_cssName : String
Sets and returns the component selector name.
JCSS_Sprite
  jcss_initialized : Boolean
[read-only] Returns true if styles already have been initialized.
JCSS_Sprite
  jcss_virtualParent : DisplayObject
Sets and gets the virtual parent of a component.
JCSS_Sprite
Protected Properties
 PropertyDefined by
  _jcssAdapter : JCSS_Adapter
The JCSS adapter.
JCSS_Sprite
Public Methods
 MethodDefined by
  
JCSS_Sprite.
JCSS_Sprite
  
cleanUp():void
JCSS_Sprite
  
Returns true, if encloseChildren() is set, else false.
JCSS_Sprite
  
jcss_clearStyle(selector:String, styleName:String = null):void
Removes a style that has formerly been set.
JCSS_Sprite
  
Executes a bulk update that was started via startBulkUpdate().
JCSS_Sprite
  
Returns the full selector of a component.
JCSS_Sprite
  
jcss_defineStyle(styleName:String, styleValue:String, format:uint, priority: = 0):void
Defines a style prior to be used with JCSS.
JCSS_Sprite
  
Declares all child component to be selectable only via this component selector.
JCSS_Sprite
  
jcss_getState(stateName:String):String
Returns the value of a component state.
JCSS_Sprite
  
jcss_getStyle(styleName:String):*
Returns the current value for the given style name.
JCSS_Sprite
  
Returns the JCSS parent chain of a componet.
JCSS_Sprite
  
jcss_setState(stateName:String, value:String):void
Sets a component state.
JCSS_Sprite
  
jcss_setStyle(selector:String, styleName:String, styleValue:uint, priority: = 1):void
Sets a style to a component instance.
JCSS_Sprite
  
jcss_setStyleSheet(styleSheet:String):void
Sets a style sheet to a component instance.
JCSS_Sprite
  
Starts a bulk update procedure.
JCSS_Sprite
  
Returns a formatted tree of all currently set style rules.
JCSS_Sprite
  
Returns a formatted String with all currently set styles.
JCSS_Sprite
Protected Methods
 MethodDefined by
  
JCSS_Sprite
  
Default handler for the styles changed event.
JCSS_Sprite
  
Default handler for the initialized event.
JCSS_Sprite
Property detail
jcssproperty
public static var jcss:JCSS
_jcssAdapterproperty 
protected var _jcssAdapter:JCSS_Adapter

The JCSS adapter.

jcss_cssClassproperty 
jcss_cssClass:String  [read-write]

Sets and returns the component css class.

Can be set initially or at runtime.

Implementation
    public function get jcss_cssClass():String
    public function set jcss_cssClass(value:String):void
jcss_cssIDproperty 
jcss_cssID:String  [read-write]

Sets and returns the component selector ID.

Can be set only initially (before the initialized event). Otherwise throws an error.

Implementation
    public function get jcss_cssID():String
    public function set jcss_cssID(value:String):void
jcss_cssNameproperty 
jcss_cssName:String  [read-write]

Sets and returns the component selector name.

Can be set only initially (before the initialized event). Otherwise throws an error.

Implementation
    public function get jcss_cssName():String
    public function set jcss_cssName(value:String):void
jcss_initializedproperty 
jcss_initialized:Boolean  [read-only]

Returns true if styles already have been initialized.

Implementation
    public function get jcss_initialized():Boolean
jcss_virtualParentproperty 
jcss_virtualParent:DisplayObject  [read-write]

Sets and gets the virtual parent of a component.

If a virtual parent is set, the component styles are calculated using the virtual parent's display list instead of the physical parent's display list. A virtual parent is a great possibility to connect components that do not have a physical parent-child relation such as tooltips or popups, which usually live in a separated container.

   CSS
   -----------------------------------------------
   Button.red ToolTip {
    color: red;
   }

   Button.blue ToolTip {
    color: blue;
   }

   Pseudo code
   -----------------------------------------------
   redButton.onMouseOver = {
    tooltip.virtualParent = redButton;
    tooltip.show(redButton.position.toGlobal());
   }

   blueButton.onMouseOver = {
    tooltip.virtualParent = blueButton;
    tooltip.show(blueButton.position.toGlobal());
   }
   

Can be set initially or at runtime.

Implementation
    public function get jcss_virtualParent():DisplayObject
    public function set jcss_virtualParent(value:DisplayObject):void
Constructor detail
JCSS_Sprite()constructor
public function JCSS_Sprite()

JCSS_Sprite.

Method detail
cleanUp()method
public function cleanUp():void
jcss_childrenEnclosed()method 
public function jcss_childrenEnclosed():Boolean

Returns true, if encloseChildren() is set, else false.

Returns
Boolean
jcss_clearStyle()method 
public function jcss_clearStyle(selector:String, styleName:String = null):void

Removes a style that has formerly been set.

If styleName is specified, the style is removed from the style rule specified with the given selector.

The method does nothing if a style rule with the given selector has not been set beforehand or a style with the given styleName has not been declared within the style rule described by the given selector.

Using this method to clear styles set to the component directly (by passing the selector "This" or "") will reset the style to its default value specified by the component.

Parameters
selector:String — A selector that matchs a particular component.
 
styleName:String (default = null) — The name of the style to remove.
jcss_commitBulkUpdate()method 
public function jcss_commitBulkUpdate():void

Executes a bulk update that was started via startBulkUpdate().

Affected components are notified only once regardless of the specific changes between startBulkUpdate() and this command.

Ancestor components are always notified before their children. A further order is not specified. It can be possible that children of different branches are notified alternating, e.g. C-1, C-2, C-2.1, C-2.2, C-1.3, C-2.4, C-1.1

jcss_componentSelectorAsString()method 
public function jcss_componentSelectorAsString():String

Returns the full selector of a component.

E.g. Box#mini.highlight

Returns
String — The component selector.
jcss_defineStyle()method 
public function jcss_defineStyle(styleName:String, styleValue:String, format:uint, priority: = 0):void

Defines a style prior to be used with JCSS.

Styles need to be defined initially. Not initially defined styles are ignored and never affect the particular component.

Styles can only be defined initially (before the initialized event). Otherwise an error is thrown.

Parameters
styleName:String — The name of the style of a component.
 
styleValue:String — The initial value of the component style.
 
format:uint — The key of the formatter of the style value.
 
priority: (default = 0) — Style priority (default, fix, important).
jcss_encloseChildren()method 
public function jcss_encloseChildren():void

Declares all child component to be selectable only via this component selector.

Enclosing children is useful when setting up stateful default styles that should not be overriden by accident. In example, we create a Button with several states and default styles that affect the contained label color. Setting now a global label color would override the Button declarations and make the label state insensitive. Invoking encloseChildren() lets match only styles rules that include this component in the selector chain.:

   Without encloseChildren();
   -----------------------------------------------
   myButton.setStyle(":over Label", "color", "red", "default"); // Button Label is red on mouse over by default.
   JCSS.getInstance().setStyle("Label", "color", "blue"); // Button Label is now blue even on mouse over.
   
   With encloseChildren();
   -----------------------------------------------
   myButton.setStyle(":over Label", "color", "red", "default"); // Button Label is red on mouse over by default.
   myButton.encloseChildren();
   JCSS.getInstance().setStyle("Label", "color", "blue"); // Does not affect the Button Label.
   JCSS.getInstance().setStyle("Button Label", "color", "blue"); // Button Label is now blue, since the selector includes Button.
   

This method can be called only initially (before the initialized event). Otherwise an error is thrown.

jcss_getState()method 
public function jcss_getState(stateName:String):String

Returns the value of a component state.

Parameters
stateName:String

Returns
String — The state value.
jcss_getStyle()method 
public function jcss_getStyle(styleName:String):*

Returns the current value for the given style name.

Returns initially (before the initialized event) null, for sure.

Parameters
styleName:String — The name of the style.

Returns
* — The current value of the style.
jcss_onStyleRulesChanged()method 
protected function jcss_onStyleRulesChanged(changedStyles:JCSS_ChangeEvent):void

Parameters
changedStyles:JCSS_ChangeEvent
jcss_onStylesChanged()method 
protected function jcss_onStylesChanged(changedStyles:JCSS_ChangeEvent):void

Default handler for the styles changed event.

Template method, to be overridden in a sub class.

Parameters
changedStyles:JCSS_ChangeEvent — All recently changed styles.
jcss_onStylesInitialized()method 
protected function jcss_onStylesInitialized():void

Default handler for the initialized event.

Template method, to be overridden in a sub class.

jcss_parentChainAsString()method 
public function jcss_parentChainAsString():String

Returns the JCSS parent chain of a componet.

E.g. Box#mini.highlight(64) < Box(56) < Box(48) < Box.blue(39)

Returns
String — The parent chain of a component.
jcss_setState()method 
public function jcss_setState(stateName:String, value:String):void

Sets a component state.

Can be set initially or at runtime.

Parameters
stateName:String — The name of the state.
 
value:String — The value of the state.
jcss_setStyle()method 
public function jcss_setStyle(selector:String, styleName:String, styleValue:uint, priority: = 1):void

Sets a style to a component instance.

It is possible to repeatedly invoke this method with equal style rules. They are then merged together for performance reasons, no worries, too.

Parameters
selector:String — A selector that matchs a particular component.
 
styleName:String — The name of the style to set.
 
styleValue:uint — The value of the style to set.
 
priority: (default = 1) — The style priority (null, "!important" or "default").
jcss_setStyleSheet()method 
public function jcss_setStyleSheet(styleSheet:String):void

Sets a style sheet to a component instance.

The style sheet can be loaded from an external source or created at runtime.

   var styleSheet : String = <styles><![CDATA[
    Box {
     backgroundColor: 0xFF0000;
    }
   ]]></styles>.toString()
   

It is possible to repeatedly invoke this method with different style sheets. Equal style rules in different or the same sheet are merged together for performance reasons, no worries.

Parameters
styleSheet:String — The stylesheet to set.
jcss_startBulkUpdate()method 
public function jcss_startBulkUpdate():void

Starts a bulk update procedure.

If invoked, affected components are buffered and notified only once after a later call of commitBulkUpdate(). If there are different styles or state to set, that might affect a particular multiple times, it is recommended to wrap the update in the bulk transaction.

jcss_styleRuleTreeAsString()method 
public function jcss_styleRuleTreeAsString():String

Returns a formatted tree of all currently set style rules.

The following example shows a style sheet and its tree representation.

   var styleSheet : String = <styles><![CDATA[
   
       ToolTip {
           borderSize: 0;
       }
   
       Blue {
           backgroundColor: #0000CC;
           borderColor: #000066;
           color: #FFFFFF;
       }
   
       Blue ToolTip {
           backgroundColor: #6666FF;
           color: #FFFFFF;
       }
   
       Red {
           backgroundColor: #CC0000;
           borderColor: #660000;
           color: #FFFFFF;
       }
   
       Red ToolTip {
           backgroundColor: #FF6666;
           color: #FFFFFF;
       }
   
       Yellow {
           backgroundColor: #CCCC00;
           borderColor: #666600;
       }
   
       Yellow ToolTip {
           backgroundColor: #FFFF66;
       }
   
   ]]></styles>.toString();
   
   [This 2]
   |_____[Yellow 22]
       | >This Yellow specifity:2 {
       |    backgroundColor: #CCCC00 (12);
       |    borderColor: #666600 (13);
       | }
       |_____[ToolTip 26]
           | >This Yellow ToolTip specifity:3 {
           |    backgroundColor: #FFFF66 (14);
           | }
   |_____[Blue 8]
       | >This Blue specifity:2 {
       |    backgroundColor: #0000CC (2);
       |    color: #FFFFFF (4);
       |    borderColor: #000066 (3);
       | }
       |_____[ToolTip 12]
           | >This Blue ToolTip specifity:3 {
           |    backgroundColor: #6666FF (5);
           |    color: #FFFFFF (6);
           | }
   |_____[ToolTip 5]
       | >This ToolTip specifity:2 {
       |    borderSize: 0 (1);
       | }
   |_____[Red 15]
       | >This Red specifity:2 {
       |    backgroundColor: #CC0000 (7);
       |    color: #FFFFFF (9);
       |    borderColor: #660000 (8);
       | }
       |_____[ToolTip 19]
           | >This Red ToolTip specifity:3 {
           |    backgroundColor: #FF6666 (10);
           |    color: #FFFFFF (11);
           | }
   

Returns
String
jcss_stylesAsString()method 
public function jcss_stylesAsString():String

Returns a formatted String with all currently set styles.

   Styles for Box#mini.highlight(64) < Box(56) < Box(48) < Box.blue(39)

   borderColor: 255;
   ------------------------------ specifity:103 timestamp:7
   backgroundColor: 16777215;
   ------------------------------ specifity:3 timestamp:11
   borderAlpha: 0.5;
   ------------------------------ specifity:2 timestamp:2
   color: 0 default;
   ------------------------------ specifity:40001 timestamp:35
   borderSize: 1;
   ------------------------------ specifity:2 timestamp:1
   

Returns
String — Currently set styles in a formatted string.