here are some ideas...

second case first...

you could create a TermsCode object with the fields code and
description and a magic toString() function, something like this...

package blah
{
public class TermsCode
{
public var code:String;
public var description:String;
public function toString():String{return description;}
}
}

and populate it with whatever gets returned from your db call.  how
you do that will depend entirely on your data access tier.  Having
populated the array you can then just bind the dataProvider of your
combo to a collection of these classes and the display will be taken
from toString().  You can then either use selectedItem or
selectedObject on the combo object to manage your selection.

for the first one you have a couple of choices and you'll have to
decide how to go based on extensibility etc. of your app.  

Since there are so few things in your list you could just create a
static array of strings with your descripive text in it and
stick-handle the value of the selected index based on inspection of
the text field, i.e.

if (it = "A")
{
myCombo.selectedIndex = 1;
}
else if (it = "B")
{
myCombo.selectedIndex = 2;
}
etc.

If you wanted to be clever you could probably create an array of
objects indexed by the value of the letter using the somewhat
mysterious object syntax

var x:Object = {}

If you are afraid to tread in those murky waters (as I am) then there
is an interesting possible alternative offered here

http://www.ericfeminella.com/blog/2006/12/05/as3-hashmap-for-flex/

which is a hashmap.

best of luck.

--- In flexcoders@yahoogroups.com, "boy_trike" <[EMAIL PROTECTED]> wrote:
>
> I have an maintenance screen with a couple of combo boxes.  One of
> them has 4 static options, the other one is loaded from a database
> with about 40-50 choices.  Here is my question:
> 
> I want to display the "correct" values in the combo box after I read
> the record to be displayed.  What is the best way to "convert" my data
> from the file to the correct index / item in the combo box?  In the
> first case, I am storing a single character A,B,O or E and I have one
> of 4 strings / labels to be displayed.  In the 2nd case, I have a
> terms code (2 characters) and my query result returns terms code,
> description and I want the description displayed.
> 
> Thanks
> Bruce
>


Reply via email to