views:

343

answers:

1

Lets say I have five text boxes and a dropdown box in my flex application, how can I make the progress bar fill up when there is text in each box, and the dropdown selected.

For example, if there is input in three out of five of the boxes and there is a selection in the dropdown, then the progress bar would be 4/6 full.

A: 

Detect changes on each of the components (Event.CHANGE, or relevant events for the controls). Then have the handler for them all which iterates the 6 components and detects their states.

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;

Crude, but it should work.

Glenn
Thanks, that's more or less what I came up with, and I was wondering if there was a better way. I didn't think of the ".text ? 1 : 0;" though, I'm ashamed to say.
Iuvat
Also, Flex says prg.Bar.value is readonly, so http://blog.flexexamples.com/2008/02/16/setting-the-value-of-a-flex-progress-bar/works instead.
Iuvat