[转]NumericStepper添加百分号

102 篇文章 0 订阅
72 篇文章 0 订阅

请问 NumericStepper组件中添加百分号

最佳答案ticore
本帖最后由 ticore 于 2011-7-26 15:50 编辑

自訂一個 MyNumericStepperSkin.mxml 套用到 NumericStepper 上

在 MyNumericStepperSkin.mxml 裡面的 <s:TextInput id="textDisplay"  />

再自訂一個 MyNumericStepperTextInputSkin.mxml

加一個 Label 顯示 % 就好了
  1. ...
  2.     <!-- text -->
  3.     <!--- @copy spark.components.supportClasses.SkinnableTextBase#textDisplay -->
  4.     <s:RichEditableText id="textDisplay"
  5.               lineBreak="explicit"
  6.               verticalAlign="middle"
  7.               multiline="false"
  8.               left="1" right="1" top="1" bottom="1" 
  9.               paddingLeft="3" paddingTop="6"
  10.               paddingRight="6" paddingBottom="3"/>

  11.         <s:Label text="%" verticalAlign="middle" right="3" top="1" bottom="1"  />
  12. .....
复制代码
textDisplay.right = 14 + 1;
為了拉開右邊的空白給 % 用
  1. ...
  2.         override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
  3.         {
  4.             if (getStyle("borderVisible") == true)
  5.             {
  6.                 border.visible = true;
  7.                 shadow.visible = true;
  8.                 background.left = background.top = background.right = background.bottom = 1;
  9.                 textDisplay.left = textDisplay.top = textDisplay.right = textDisplay.bottom = 1;
  10.                                 textDisplay.right = 14 + 1;
  11.             }
  12.             else
  13.             {
  14.                 border.visible = false;
  15.                 shadow.visible = false;
  16.                 background.left = background.top = background.right = background.bottom = 0;
  17.                 textDisplay.left = textDisplay.top = textDisplay.right = textDisplay.bottom = 0;
  18.                                 textDisplay.right = 10;
  19.             }
  20.             
  21.             borderStroke.color = getStyle("borderColor");
  22.             borderStroke.alpha = getStyle("borderAlpha");
  23.             
  24.             super.updateDisplayList(unscaledWidth, unscaledHeight);
  25.         }
  26. ....
复制代码
最後顯示效果像這樣
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值