flex學習筆記 state(一)

flex4 API裏面介紹:ide

    State 類定義視圖狀態,即組件的特定視圖。例如,產品縮略圖能夠有兩個視圖狀態,包含最少信息的基本視圖狀態和包含附加信息的豐富視圖狀態。overrides 屬性指定一組要添加到基本視圖狀態或從基本視圖狀態中刪除的子類,以及當視圖狀態有效時要設置的屬性、樣式和事件處理函數。函數

能夠在 Flex 組件的 states 屬性中使用 State 類。只能在應用程序或自定義控件的根中指定 states 屬性,而不能在子控件中指定。flex

可經過設置組件的 currentState 屬性來啓用視圖狀態。spa

1、 狀態的定義:code

  只需在<states></states>標籤內定義狀態就能夠了。xml

 

  
  
           
  
  
  1. <s:states> 
  2.     <s:State name="default"/> 
  3.     <s:State name="selected"/> 
  4. </s:states> 

2、 狀態的改變:事件

可經過改變組件的 currentState 屬性來更換狀態。產品

 

  
  
           
  
  
  1. <s:Button label="123123"  label.selected="44455" click="currentState='selected';" click.selected="currentState='default';"/> 
  2.    <s:Button label="hello"  label.selected="world"  click="currentState='selected';" click.selected="currentState='default';"/> 

label="hello"  label.selected="world"  表示狀態對應的效果it

效果就是:點擊按鈕 按鈕會改變狀態,文本會發生變化。class

相關文章
相關標籤/搜索