2011-04-03 73 views
0

爲什麼第一個跟蹤打印出沒有第二個,而我設置在屬性面板中的「hello」的標籤?閃光燈無法單選按鈕標籤比較字符串

public function OnClick(event:MouseEvent) { 
      trace(event.target.label.toString()); 
    if (event.target.label.toString() == "hello") { 
     trace("hello");   
    }; 
    } 

回答

1

它爲我的作品... ATLEAST與此代碼:

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

誤差必須在其他地方

+0

哎呀,是我做鬼大寫的地方。 – user310291 2011-04-03 21:42:27

1

就個人而言,我猜想,有在標籤的額外空間偶然。

嘗試trace(event.target.label.toString().length);如果不是5,這就是你的問題。