2

这是我拥有的代码示例。当移动应用程序打开时,您可以输入您想要的颜色(例如,#811fb4 为紫色),当您单击按钮时,它应该会更改标签颜色。但是 lbl1.color 不起作用。有任何想法吗?

 <?xml version="1.0" encoding="utf-8"?>
 <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" title="Custom Colour">

<fx:Script>
    <![CDATA[
        public var customColourChosen:String;

        protected function button1_clickHandler(event:MouseEvent):void{
            customColourChosen = txtInput1.text;
            lbl1.color = customColourChosen; // <------ //
        }

    ]]>
</fx:Script>

<s:Label id="lbl1" x="144" y="104" fontSize="36" text="Label"/>
<s:TextInput id="txtInput1" x="50" y="138"/>
<s:Button x="124" y="212" label="Button" click="button1_clickHandler(event)"/>
</s:View>
4

1 回答 1

0
lbl1.setStyle('color', 0xff0000);

这样你甚至可以使用紫色我认为.. :)

于 2012-12-04T22:49:49.663 回答