2009-07-09 43 views
0

假設我的Flex應用程序中有五個文本框和一個下拉框,當每個框中有文本並選擇下拉列表時,如何填充進度欄。

例如,如果在五個框中有三個輸入並且在下拉框中有選擇,則進度條將是4/6滿。由論壇條目控制的Flex進度條

回答

0

檢測每個組件(Event.CHANGE或控件的相關事件)上的更改。然後爲它們設置處理程序,它們遍歷6個組件並檢測它們的狀態。

var progressCount:NUmber = 0; 
progressCount += txtArea1.text ? 1 : 0; 
progressCount += txtArea2.text ? 1 : 0; 
progressCount += txtArea3.text ? 1 : 0; 
progressCount += txtArea4.text ? 1 : 0; 
progressCount += txtArea5.text ? 1 : 0; 
progressCount += cmbBox.selectedItem ? 1 : 0; 

prgBar.value = progressCount; 

原油,但它應該工作。

+0

謝謝,這或多或少是我想出的,我想知道是否有更好的方法。我沒有想到「.text?1:0」。儘管如此,我很慚愧地說。 – Davis 2009-07-09 15:17:01

+0

另外,Flex說prg.Bar.value是隻讀的,所以http://blog.flexexamples.com/2008/02/16/setting-the-value-of-a-flex-progress-bar/ 可以代替。 – Davis 2009-07-09 15:30:08