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 variant property.

Alternate functions may be registered with the style provider by calling setStyleFunction() and passing in a variant name and a function. The style provider will search its registered variants to see if a function should be called. If the component's variant has not been registered with the style provider (or if the component has no variant), then the default style function will be called.

In the following example, a ClassVariantStyleProvider is created with a a default style function and an alternate style function:

var styleProvider:ClassVariantStyleProvider = new ClassVariantStyleProvider();
styleProvider.setFunctionForStyleName(Button, null, function(target:Button):Void {
	target.backgroundSkin = new Bitmap(bitmapData);
	// set other styles...
});
styleProvider.setFunctionForStyleName(Button, "alternate-button", function(target:Button):Void {
	target.backgroundSkin = new Bitmap(alternateBitmapData);
	// 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.variant = "alternate-button";
this.addChild(alternateButton);
Available since

1.0.0

.

See:

Constructor

new (?target:IEventDispatcher)

Methods

applyStyles (target:IStyleObject):Void

Applies styles to a specific Feathers UI component.

Available since

1.0.0

.

getStyleFunction<T> (type:Class<T>, variant:String):T ‑> Void

Gets a style function registered with setStyleFunction).

Available since

1.0.0

.

setStyleFunction<T> (type:Class<T>, variant:String, callback:T ‑> Void):Void

The target Feathers UI component is passed to this function when applyStyles() is called and the component's variant property contains the specified value.

The function is expected to have the following signature:

hx (IStyleObject) -> Void

Available since

1.0.0

.