Packagefeathers.skins
Classpublic class StyleNameFunctionStyleProvider
InheritanceStyleNameFunctionStyleProvider Inheritance Object
Implements IStyleProvider

Product Version : Feathers 2.0.0

Similar to FunctionStyleProvider, sets styles on a Feathers UI component by passing it to a function, but also provides a way to define alternate functions that may be called based on the contents of the component's styleNameList.

Alternate functions may be registered with the style provider by calling setFunctionForStyleName() and passing in a style name and a function. For each style name in the component's styleNameList, the style provider will search its registered style names to see if a function should be called. If none of a component's style names have been registered with the style provider (or if the component has no style names), then the default style function will be called.

If a component's styleNameList contains multiple values, each of those values is eligible to trigger a call to a function registered with the style provider. In other words, adding multiple values to a component's styleNameList may be used to call multiple functions.

In the following example, a StyleNameFunctionStyleProvider is created with a default style function (passed to the constructor) and an alternate style function:

var styleProvider:StyleNameFunctionStyleProvider = new StyleNameFunctionStyleProvider( function( target:Button ):void
{
    target.defaultSkin = new Image( defaultTexture );
    // set other styles...
});
styleProvider.setFunctionForStyleName( "alternate-button", function( target:Button ):void
{
    target.defaultSkin = new Image( alternateTexture );
    // set other styles...
});

var button:Button = new Button();
button.label = "Click Me";
button.styleProvider = styleProvider;
this.addChild(button);

var alternateButton:Button = new Button()
button.label = "No, click me!";
alternateButton.styleProvider = styleProvider;
alternateButton.styleNameList.add( "alternate-button" );
this.addChild( alternateButton );

See also

Skinning Feathers components


Public Properties
 PropertyDefined By
  defaultStyleFunction : Function
The target Feathers UI component is passed to this function when applyStyles() is called and the component's styleNameList doesn't contain any style names that are set with setFunctionForStyleName().
StyleNameFunctionStyleProvider
Public Methods
 MethodDefined By
  
StyleNameFunctionStyleProvider(styleFunction:Function = null)
Constructor.
StyleNameFunctionStyleProvider
  
Applies styles to a specific Feathers UI component, unless that component has been excluded.
StyleNameFunctionStyleProvider
  
setFunctionForStyleName(styleName:String, styleFunction:Function):void
The target Feathers UI component is passed to this function when applyStyles() is called and the component's styleNameList contains the specified style name.
StyleNameFunctionStyleProvider
Property Detail
defaultStyleFunctionproperty
defaultStyleFunction:Function

The target Feathers UI component is passed to this function when applyStyles() is called and the component's styleNameList doesn't contain any style names that are set with setFunctionForStyleName().

The function is expected to have the following signature:

function( item:IFeathersControl ):void


Implementation
    public function get defaultStyleFunction():Function
    public function set defaultStyleFunction(value:Function):void

See also

Constructor Detail
StyleNameFunctionStyleProvider()Constructor
public function StyleNameFunctionStyleProvider(styleFunction:Function = null)

Constructor.

Parameters
styleFunction:Function (default = null)
Method Detail
applyStyles()method
public function applyStyles(target:IFeathersControl):void

Applies styles to a specific Feathers UI component, unless that component has been excluded.

Parameters

target:IFeathersControl

setFunctionForStyleName()method 
public function setFunctionForStyleName(styleName:String, styleFunction:Function):void

The target Feathers UI component is passed to this function when applyStyles() is called and the component's styleNameList contains the specified style name.

The function is expected to have the following signature:

function( item:IFeathersControl ):void

Parameters

styleName:String
 
styleFunction:Function

See also