I'd expect that introducing an unnecessary
local var would make it slightly less efficient, but I haven't looked at the
bytecode for the two cases.
- Gordon
From:
[email protected] [mailto:[EMAIL PROTECTED] On Behalf Of jeremy lu
Sent: Monday, May 15, 2006 7:01 PM
To: [email protected]
Subject: Re: [flexcoders] FB2B3
programmatically select an item in a ComboBox
glad that helped.
adding var itm:* = cboCountry.dataProvider.getItemAt(i) might be a little
bit efficient.
On 5/16/06, Steve
Gustafson <[EMAIL PROTECTED]>
wrote:
That solved it!
The key is using the dataProvider.length instead of the ComboBox .length
I shortened the code block a little to:
for(var i:Number = 0; i < cboCountry.dataProvider.length ;
i++)
{
if (cboCountry.dataProvider.getItemAt(i).data ==
event.result.COUNTRY)
{
cboCountry.selectedIndex = i;
break;
}
}
Thanks for the help!
On 5/15/06, jeremy
lu <[EMAIL PROTECTED]>
wrote:
well, I believe all the getItemAt() methods are removed from List-base
components like Combobox, List, DataGrid in F2B3.
to do the loop correctly, try this:
for(var i:Number = 0; i < cboCountry.dataProvider.length; i++)
{
var itm:* = cboCountry.dataProvider.getItemAt(i);
if( itm.data == event.result.COUNTRY )
{
cboCountry.selectedIndex = i;
break;
}
}
On 5/16/06, Simeon
Bateman <[EMAIL PROTECTED]
> wrote:
Well I dont know exactly what is wrong, but using flex builder it would
be pretty easy to set a break point on the "if" line of code and then
step through the loop to ensure that those to variables are what you think they
should be.
I use a mac and so my solution is to just use an alert to pop up the 2 items
each loop so I can compare them.
Give it a look, you might find that the two don't actually match up.
The other thing, is that if you are doing this on a tabnavigator or accordian
and the page you are setting has not yet been drawn then the items wont get
selected even if they match. If this is the case you might have to look
into the creationPolicy for the parent, to ensure the children are all created
before you try to set properties on them.
Hope that helps.
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO!
GROUPS LINKS
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO!
GROUPS LINKS
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS
|
- RE: [flexcoders] FB2B3 programmatically select an item in a C... Gordon Smith
-