我在动作脚本中有一个按钮,其中toggle =“true”。现在,当我单击按钮时,它的颜色会发生变化,看起来好像已经被禁用了(但实际上并没有)。我需要知道这个按钮的哪个属性已经改变了?例如,如果我需要在我的代码中的某个地方知道这个按钮的“切换状态”(如果有这样的话),我应该检查这个按钮的哪个属性?
感谢。
答案 0 :(得分:0)
Button.selected
正是您所寻找的,我举了一个例子来证明这一点:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init(event)">
<mx:Script>
<![CDATA[
import flash.events.MouseEvent;
import mx.events.FlexEvent;
private function init(e:FlexEvent):void
{
onButtonClick();
}// end function
protected function onButtonClick(e:MouseEvent = null):void
{
if (button.selected) button.label = "button selected"
else button.label = "button not selected";
}// end function
]]>
</mx:Script>
<mx:Button id="button" toggle="true" click="onButtonClick()"></mx:Button>
</mx:Application>