[转]NumericStepper添加百分号
请问 NumericStepper组件中添加百分号
最佳答案 ticore ![]()
本帖最后由 ticore 于 2011-7-26 15:50 编辑
自訂一個 MyNumericStepperSkin.mxml 套用到 NumericStepper 上
在 MyNumericStepperSkin.mxml 裡面的 <s:TextInput id="textDisplay" />
再自訂一個 MyNumericStepperTextInputSkin.mxml
加一個 Label 顯示 % 就好了
- ...
- <!-- text -->
- <!--- @copy spark.components.supportClasses.SkinnableTextBase#textDisplay -->
- <s:RichEditableText id="textDisplay"
- lineBreak="explicit"
- verticalAlign="middle"
- multiline="false"
- left="1" right="1" top="1" bottom="1"
- paddingLeft="3" paddingTop="6"
- paddingRight="6" paddingBottom="3"/>
- <s:Label text="%" verticalAlign="middle" right="3" top="1" bottom="1" />
- .....
复制代码
textDisplay.right = 14 + 1;
為了拉開右邊的空白給 % 用
- ...
- override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
- {
- if (getStyle("borderVisible") == true)
- {
- border.visible = true;
- shadow.visible = true;
- background.left = background.top = background.right = background.bottom = 1;
- textDisplay.left = textDisplay.top = textDisplay.right = textDisplay.bottom = 1;
- textDisplay.right = 14 + 1;
- }
- else
- {
- border.visible = false;
- shadow.visible = false;
- background.left = background.top = background.right = background.bottom = 0;
- textDisplay.left = textDisplay.top = textDisplay.right = textDisplay.bottom = 0;
- textDisplay.right = 10;
- }
- borderStroke.color = getStyle("borderColor");
- borderStroke.alpha = getStyle("borderAlpha");
- super.updateDisplayList(unscaledWidth, unscaledHeight);
- }
- ....
复制代码
最後顯示效果像這樣