How do I set the color of a NumericStepper?

67 Views Asked by At

I have already looked at this question:How to change the text color in NumericStepper the link referenced is broken.

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. Nothing has worked. What is going on?

1

There are 1 best solutions below

0
Justin Mclean On

To Change the colour of the text just use setStyle like so.

<?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.