Binding to functions is tricky.  It doesn't know when its value changed.
Binding to something that does is better.  The function probably gets
run at init time and errors which is eaten by Binding then never knows
that the results came back.  I would set selectedIndex in the results
handler.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of hammer995
Sent: Monday, September 17, 2007 2:51 PM
To: [email protected]
Subject: [flexcoders] ComboBox SelectedIndex HELP!

 

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;
}

 

Reply via email to