「Extending Feathers Themes(リンク先へ)」
を参考にしています。
スキンの状態を赤青緑の矩形に変更してみます。
スキン用の矩形
FeathersThemeライブラリプロジェクトにスキン用の矩形と
カスタムテーマExtendMetalWorksThemeを追加します。
ExtendMetalWorksTheme.as
package feathers.themes { import feathers.controls.Button; import feathers.themes.MetalWorksMobileTheme; import starling.display.DisplayObjectContainer; import starling.display.Image; import starling.textures.Texture; public class ExtendMetalWorksTheme extends MetalWorksMobileTheme { public static const ALTERNATE_NAME_MY_CUSTOM_BUTTON:String = "my-custom-button"; [Embed(source="./assets/buttons/blue.png")] public var blueClass:Class; [Embed(source="./assets/buttons/green.png")] public var greenClass:Class; [Embed(source="./assets/buttons/red.png")] public var redClass:Class; public function ExtendMetalWorksTheme(root:DisplayObjectContainer, scaleToDPI:Boolean=true) { super(root, scaleToDPI); } override protected function initialize():void { super.initialize(); this.setInitializerForClass(Button, myCustomButtonInitializer, ALTERNATE_NAME_MY_CUSTOM_BUTTON); } private function myCustomButtonInitializer(button:Button):void { button.defaultSkin = new Image( Texture.fromBitmap(new blueClass()) ); button.downSkin = new Image( Texture.fromBitmap(new greenClass()) ); button.hoverSkin = new Image( Texture.fromBitmap(new redClass()) ); button.defaultLabelProperties.textFormat = this.smallUILightTextFormat; button.disabledLabelProperties.textFormat = this.smallUIDisabledTextFormat; button.selectedDisabledLabelProperties.textFormat = this.smallUIDisabledTextFormat; } } }FeathersThemeライブラリプロジェクトをビルドします。
FeathersExampleプロジェクトのButtonExample.as内でカスタムテーマの変更をします。
ButtonExample.as
protected var theme:ExtendMetalWorksTheme;
themeIndex = 2; switch(themeIndex) { case 0: //this.theme = new MetalWorksMobileTheme(this.stage); break; case 1: //this.theme = new AeonDesktopTheme(this.stage); break; case 2: this.theme = new ExtendMetalWorksTheme(this.stage); break; }
0 件のコメント:
コメントを投稿