加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex中如何设置Alert背景图片的例子

发布时间:2020-12-15 05:04:02 所属栏目:百科 来源:网络整理
导读:http://blog.minidx.com/2009/11/05/3021.html 下面是main.mxml: ? xml version = " 1.0 " encoding = " utf-8 " ? s:Application name = " Halo_Alert_borderSkin_test " xmlns:fx = " http://ns.adobe.com/mxml/2009 xmlns:s = " library://ns.adobe.com/

http://blog.minidx.com/2009/11/05/3021.html

下面是main.mxml:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <s:Application name="Halo_Alert_borderSkin_test"
  3. xmlns:fx="http://ns.adobe.com/mxml/2009xmlns:s="library://ns.adobe.com/flex/sparkxmlns:mx="library://ns.adobe.com/flex/halo">
  4. ?
  5. <fx:Style>
  6. @namespace s "library://ns.adobe.com/flex/spark";
  7. @namespace mx "library://ns.adobe.com/flex/halo";
  8. ?
  9. mx|Alert {
  10. borderSkin: ClassReference("skins.CustomPanelBorderSkin");
  11. }
  12. </fx:Style>
  13. ?
  14. <fx:Script>
  15. <![CDATA[
  16. import mx.controls.Alert;
  17. ?
  18. protected function btn_clickHandler(evt:MouseEvent):void {
  19. var a:Alert = Alert.show("The quick brown fox jumps over the lazy dog","Alert title");
  20. a.status = mx_internal::VERSION;
  21. }
  22. ]]>
  23. </fx:Script>
  24. ?
  25. <mx:ApplicationControlBar width="100%cornerRadius="0">
  26. <s:Button id="btnlabel="Launch Alertclick="btn_clickHandler(event);" />
  27. </mx:ApplicationControlBar>
  28. ?
  29. </s:Application>

下面为skins/CustomPanelBorderSkin.mxml的代码:

  1. <?xml "?>
  2. <s:SparkSkin "CustomPanelBorderSkinimplements="mx.core.IRectangularBorder">
  3. ?
  4. <fx:Script>
  5. import mx.core.EdgeMetrics;
  6. import mx.core.IUIComponent;
  7. ?
  8. /* Define the skin elements that should not be colorized.
  9. For panel,border and title backround are skinned,but the content area and title text are not. */
  10. static private const exclusions:Array = ["background"];
  11. override public function get colorizeExclusions():Array {
  12. return exclusions;
  13. }
  14. ?
  15. /* Define the content fill items that should be colored by the "contentBackgroundColor" style. */
  16. static private const contentFill:Array = [];
  17. override public function get contentItems():Array {
  18. return contentFill
  19. };
  20. ?
  21. private var _metrics:EdgeMetrics = new EdgeMetrics(1,32,1,1);
  22. public function get borderMetrics():EdgeMetrics {
  23. var hasPanelParent:Boolean = isPanel(parent);
  24. var controlBar:IUIComponent = hasPanelParent ? Object(parent).mx_internal::_controlBar : null;
  25. if (controlBar && controlBar.includeInLayout) {
  26. _metrics.bottom = controlBar.getExplicitOrMeasuredHeight() + 1;
  27. } else {
  28. _metrics.bottom = 1;
  29. return _metrics;
  30. public function get backgroundImageBounds():Rectangle {
  31. return null;
  32. public function set backgroundImageBounds(value:Rectangle):void {
  33. public function get hasBackgroundImage():Boolean {
  34. return false;
  35. public function layoutBackgroundImage():void {
  36. override protected function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void {
  37. var em:EdgeMetrics = borderMetrics;
  38. if (em.bottom > 1) {
  39. cbbg.height = em.bottom - 1;
  40. cbdiv.bottom = cbbg.height;
  41. cbbg.visible = cbdiv.visible = true;
  42. cbbg.visible = cbdiv.visible = false;
  43. super.updateDisplayList(unscaledWidth,unscaledHeight);
  44. private static var panels:Object = {};
  45. ?
  46. private static function isPanel(parent:Object):Boolean {
  47. var s:String = getQualifiedClassName(parent);
  48. if (panels[s] == 1) {
  49. return true;
  50. if (panels[s] == 0) {
  51. if (s == "mx.containers::Panel") {
  52. panels[s] == 1;
  53. var x:XML = describeType(parent);
  54. var xmllist:XMLList = x.extendsClass.(@type == "mx.containers::Panel");
  55. if (xmllist.length() == 0) {
  56. panels[s] = 0;
  57. panels[s] = 1;
  58. ]]>
  59. </fx:Script>
  60. ?
  61. <!-- drop shadow -->
  62. <s:Rect left=top=right=bottom=">
  63. <s:filters>
  64. <s:DropShadowFilter blurX="20blurY=alpha="0.32distance="11angle="90knockout="true" />
  65. </s:filters>
  66. <s:fill>
  67. <s:SolidColor color=" />
  68. </s:fill>
  69. </s:Rect>
  70. ?
  71. <!-- layer 1: border -->
  72. <s:Rect ">
  73. <s:stroke>
  74. <s:SolidColorStroke "0.50weight="1" />
  75. </s:stroke>
  76. </s:Rect>
  77. ?
  78. <!-- layer 2: background fill -->
  79. <s:Rect "background"0.6">
  80. <s:fill>
  81. <s:BitmapFill source="@Embed('assets/pattern_158.gif')<!-- layer 3: title bar fill -->
  82. <s:Rect height="30">
  83. <s:fill>
  84. <s:LinearGradient rotation=">
  85. <s:GradientEntry "0xE2E2E2" />
  86. <s:GradientEntry "0xD9D9D9" />
  87. </s:LinearGradient>
  88. </s:fill>
  89. </s:Rect>
  90. ?
  91. <!-- layer 4: title bar highlight -->
  92. <s:Rect ">
  93. <s:stroke>
  94. <s:LinearGradientStroke "0xEAEAEA" />
  95. </s:LinearGradientStroke>
  96. </s:stroke>
  97. </s:Rect>
  98. <s:Rect "31">
  99. <s:fill>
  100. <s:SolidColor "0xC0C0C0<!-- layer 5: control bar background -->
  101. <s:Rect "cbbg"0xE8E8E8<!-- layer 6: control bar divider line -->
  102. <s:Rect "cbdiv"0xCDCDCD" />
  103. </s:fill>
  104. </s:Rect>
  105. ?
  106. </s:SparkSkin>

效果如下:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读