如何使用按钮更改标签的颜色? Flash Builder 4.6

时间:2012-12-04 22:00:40

标签: android actionscript-3 flash-builder

这是我的代码示例。 当移动应用程序打开时,您可以键入所需的颜色(例如,#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>

1 个答案:

答案 0 :(得分:0)

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

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

相关问题