So I have an edit form which I have several combobox's that I can
populate successfully from static arrays. So I want to duplicate this
with results from an HTTPService.
For some reason, the selectedIndex property does not run the function
for selecting the data to be shown by default.
The HTTPService gets launched at creationComplete when the user
selects the edit component.
I actually never get the trace in the findIndexAcct so that leads me
to believe that it never gets executed.
This is my code:
<!-- COMBO BOX -->
<mx:ComboBox id="acctComboBox" width="115"
dataProvider="{getAcctListOnly.lastResult.customers.customer}"
close="selectedItemAcct=ComboBox(event.target).selectedItem"
openDuration="500"
openEasingFunction="Bounce.easeOut"
closeDuration="500"
closeEasingFunction="Bounce.easeIn"
selectedIndex="{findIndexAcct(data.acct)}"
alternatingItemColors="[0xDFDFDF, 0xEEEEEE]"
labelField="acct"
cornerRadius="5"/>
<!-- FUNCTION -->
[Bindable]
public var acctArray:ArrayCollection;
private function
getAcctListResultHandler(event:ResultEvent): void {
acctArray = event.result.customers.customer as
ArrayCollection;
/*
for (var i:int = 0; i < acctArray.length; i++) {
trace(acctArray[i].acct);
} */
}
private function findIndexAcct(acct:String):int {
var index:int = -1;
for (var i:int = 0; i < acctArray.length; i++) {
if ( acct == acctArray[i].acct) {
index = i;
}
}
trace(index);
return index;
}