2010-04-26 234 views
0

我想單擊時更改按鈕外觀。點擊更改按鈕外觀

<?xml version="1.0" encoding="utf-8"?> 
<s:Button xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx" 
      creationComplete="init()">   
    <fx:Script> 
     <![CDATA[ 
      public var _clicked:Boolean = false; 

      public function init():void{ 
       addEventListener(MouseEvent.CLICK, changeButtonClickStatus);    
      } 

      public function changeButtonClickStatus(event:MouseEvent):void{ 
       var that:TopMenuButton = event.currentTarget as TopMenuButton; 
       that._clicked = !(that._clicked); 

       if(that._clicked == true){ 
       //change button appearance 
       }else{ 
       //change button appearance 
       } 
      } 
     ]]> 
    </fx:Script> 
</s:Button> 

有沒有使用狀態的方法?然後我可以使用皮膚約定。 在此先感謝您的幫助。

回答

1

如果你正在尋找一個可以皮膚,然後it already exists不同狀態Flex 4中

退房的源代碼ToggleButtonSkin.mxml看看如何皮膚的不同狀態的切換按鈕。