/ Published in: ActionScript 3
An example of a Flex Mobile button skin using PNG assets and the Flash drawing API
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
package skins { import flash.display.Sprite; import spark.skins.mobile.ButtonSkin; public class ComboBoxButtonSkin extends ButtonSkin { [Bindable] [Embed(source="/assets/combobox_button_up.png")] private var up:Class; [Bindable] [Embed(source="/assets/combobox_button_down.png")] private var down:Class; protected var _triangle:Sprite; public function ComboBoxButtonSkin() { super(); upBorderSkin = up; downBorderSkin = down; _triangle = new Sprite(); } override protected function createChildren():void { super.createChildren(); addChild(_triangle); } override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void { var halfUnscaledHeight:int = Math.round(unscaledHeight/2); _triangle.graphics.beginFill(0xcee410); _triangle.graphics.moveTo(unscaledWidth-20,halfUnscaledHeight-5); _triangle.graphics.lineTo(unscaledWidth-10,halfUnscaledHeight); _triangle.graphics.lineTo(unscaledWidth-20,halfUnscaledHeight+5); _triangle.graphics.lineTo(unscaledWidth-20,halfUnscaledHeight-5); _triangle.graphics.endFill(); } } }