Flash无法将radiobutton标签与字符串进行比较
为什么第一个跟踪打印的不是第二个跟踪,而我在属性面板中将标签设置为“hello”Flash无法将radiobutton标签与字符串进行比较,flash,actionscript-3,Flash,Actionscript 3,为什么第一个跟踪打印的不是第二个跟踪,而我在属性面板中将标签设置为“hello” 它对我有用。。。至少使用此代码: <?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://
它对我有用。。。至少使用此代码:
<?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" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
protected function radiobutton1_clickHandler(event:MouseEvent):void{
trace(event.target.label.toString());
if (event.target.label.toString() == "hello") {
trace("comparison works");
};
}
]]>
</fx:Script>
<s:RadioButton label="hello" click="radiobutton1_clickHandler(event)"/>
</s:Application>
错误肯定在其他地方就我个人而言,我猜标签中意外出现了额外的空间
尝试跟踪(event.target.label.toString().length)代码>如果不是5,那就是你的问题。哦,是的,我在什么地方弄乱了大写字母。
<?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" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
protected function radiobutton1_clickHandler(event:MouseEvent):void{
trace(event.target.label.toString());
if (event.target.label.toString() == "hello") {
trace("comparison works");
};
}
]]>
</fx:Script>
<s:RadioButton label="hello" click="radiobutton1_clickHandler(event)"/>
</s:Application>