简体   繁体   English

如何设置NumericStepper的颜色?

[英]How do I set the color of a NumericStepper?

I have already looked at this question: How to change the text color in NumericStepper the link referenced is broken. 我已经看过这个问题了: 如何在NumericStepper中更改引用链接的文本颜色

I have the following code: 我有以下代码:

var sdAdopt:NumericStepper = sdAdoptGroup.getChildAt(year) as NumericStepper;
sdAdopt.textDisplay.setStyle("color","red");

it does not work. 这是行不通的。

I have also tried 我也尝试过

sdAdopt.setStyle("color", 0xFF0000);

I have also tried using a textFormatter object. 我也尝试过使用textFormatter对象。 Nothing has worked. 没事。 What is going on? 到底是怎么回事?

To Change the colour of the text just use setStyle like so. 要更改文本的颜色,只需使用setStyle即可。

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx">
    <s:layout>
        <s:VerticalLayout />
    </s:layout>

    <fx:Script>
        <![CDATA[
            protected function click(event:MouseEvent):void
            {
                ns.textDisplay.setStyle("color", 0xFF0000);
            }
        ]]>
    </fx:Script>


    <s:NumericStepper id="ns"/>
    <s:Button click="click(event)" label="Change Color" />
</s:Application>

I'm not sure why your sample code is using year in the call to getChildAt. 我不确定为什么您的示例代码在对getChildAt的调用中使用year。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM