Flex Mobile Button Skin


/ Published in: ActionScript 3
Save to your folder(s)

An example of a Flex Mobile button skin using PNG assets and the Flash drawing API


Copy this code and paste it in your HTML
  1. package skins
  2. {
  3. import flash.display.Sprite;
  4.  
  5. import spark.skins.mobile.ButtonSkin;
  6.  
  7. public class ComboBoxButtonSkin extends ButtonSkin
  8. {
  9. [Bindable]
  10. [Embed(source="/assets/combobox_button_up.png")]
  11. private var up:Class;
  12.  
  13. [Bindable]
  14. [Embed(source="/assets/combobox_button_down.png")]
  15. private var down:Class;
  16.  
  17. protected var _triangle:Sprite;
  18.  
  19. public function ComboBoxButtonSkin()
  20. {
  21. super();
  22.  
  23. upBorderSkin = up;
  24. downBorderSkin = down;
  25.  
  26. _triangle = new Sprite();
  27. }
  28.  
  29. override protected function createChildren():void
  30. {
  31. super.createChildren();
  32. addChild(_triangle);
  33.  
  34. }
  35.  
  36. override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void
  37. {
  38. var halfUnscaledHeight:int = Math.round(unscaledHeight/2);
  39.  
  40. _triangle.graphics.beginFill(0xcee410);
  41. _triangle.graphics.moveTo(unscaledWidth-20,halfUnscaledHeight-5);
  42. _triangle.graphics.lineTo(unscaledWidth-10,halfUnscaledHeight);
  43. _triangle.graphics.lineTo(unscaledWidth-20,halfUnscaledHeight+5);
  44. _triangle.graphics.lineTo(unscaledWidth-20,halfUnscaledHeight-5);
  45. _triangle.graphics.endFill();
  46. }
  47.  
  48. }
  49. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.