Posted By

tpryan on 06/05/11


Tagged


Versions (?)

Flex Mobile Button Skin


 / Published in: ActionScript 3
 

  1. package skins
  2. {
  3. import mx.events.FlexEvent;
  4.  
  5. import spark.skins.mobile.ButtonSkin;
  6.  
  7. public class DemoButton extends ButtonSkin
  8. {
  9.  
  10. //Import the new assets for the background of the button
  11. [Bindable]
  12. [Embed(source="/assets/filterbuttonDown.png")]
  13. private var down:Class;
  14.  
  15. [Bindable]
  16. [Embed(source="/assets/filterbuttonUp.png")]
  17. private var up:Class;
  18.  
  19. public function DemoButton()
  20. {
  21. super();
  22. //Set the width and the height to the size of the image.
  23. width = 243;
  24. height = 103;
  25. }
  26.  
  27. // Override this function to return our skin images and not the normal ones.
  28. override protected function getBorderClassForCurrentState():Class
  29. {
  30. if (currentState == "down"){
  31. labelDisplay.setStyle("color",0xFFFFFF);
  32. return down;
  33. }
  34. else{
  35. labelDisplay.setStyle("color",0x48250A);
  36. return up;
  37. }
  38. }
  39.  
  40. // Override this function to prvent the button from drawing a background
  41. override protected function drawBackground(unscaledWidth:Number,
  42. unscaledHeight:Number):void{
  43.  
  44. }
  45.  
  46. override protected function
  47. labelDisplay_valueCommitHandler(event:FlexEvent):void
  48. {
  49. //super.labelDisplay_valueCommitHandler(event);
  50. labelDisplayShadow.text = labelDisplay.text;
  51.  
  52. labelDisplay.setStyle("fontFamily","Lions Den");
  53. labelDisplay.setStyle("fontSize",40);
  54. labelDisplay.setStyle("fontWeight","normal");
  55. labelDisplay.setStyle("color",0x48250A);
  56. labelDisplayShadow.setStyle("fontFamily","Lions Den");
  57. labelDisplayShadow.setStyle("fontSize",40);
  58. labelDisplayShadow.setStyle("fontWeight","normal");
  59.  
  60. }
  61.  
  62. }
  63. }

Report this snippet  

You need to login to post a comment.