Re: [flexcoders] FB2B3 programmatically select an item in a ComboBox

2006-05-16 Thread jeremy lu




hi Gordon, 

that's interesting, please bring it back here if you do get time to check it, thanks :-)

btw, my rationale behind this is: player don't have to evaluate the
whole chain during the loop by assigning it to a variable, but I might
just be wrong.

On 5/16/06, Gordon Smith [EMAIL PROTECTED] wrote:
















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:
flexcoders@yahoogroups.com [mailto:
flexcoders@yahoogroups.com] On Behalf Of jeremy lu
Sent: Monday, May 15, 2006 7:01 PM
To: flexcoders@yahoogroups.com
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!





Steve 












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.






simeon











On 5/15/06, Steve
Gustafson [EMAIL PROTECTED]
wrote: 





Greetings and thanks in
advance for your help!


I have a ComboBox that displays a countries.
 The label is a country Name
 The data is a country code

I then retrieve a users record via AMF. Standard stuff with First Name,
Last Name etc. 

I am populating various fields with the retrieved data, which is working fine.

Where I am stuck is on the country ComboBox. I want to select the
appropriate country for the user.

I expected something like this to work: 


for(var i:Number = 0; i  cboCountry.length; i++) 
{
 if(cboCountry.getItemAt(i).data == event.result.COUNTRY)

 {
 cboCountry.selectedIndex = i;
 break;
 }
}

I have yet to figure out how to loop through the ComboBox to match the users
country. Or if I even need to run a loop in FB2B3.

This has got to be a very common task, yet I am not finding any decent info on
an approach. 

Any help is greatly appreciated.

Steve




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt

Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








SPONSORED
LINKS 





 
  
  
Web site design development 
  
  
  
Computer software development 
  
  
  
Software design and development 
  
 
 
  
  
Macromedia flex 
  
  
  
Software development best practice 
  
  
  
  
 










YAHOO!
GROUPS LINKS





 Visit your group 
flexcoders
 on the web.
  
 To unsubscribe from this group, send an
 email to:
  [EMAIL PROTECTED]

 
 Your use of Yahoo! Groups is subject to the
 Yahoo! Terms of
 Service .



















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





 Visit your group 
flexcoders
 on the web.
  
 To unsubscribe from this group, send an
 email to:
  [EMAIL PROTECTED]

 
 Your use of Yahoo! Groups is subject to the
 Yahoo! Terms
 of Service .



















--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt

Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








SPONSORED
LINKS 





 
  
  
Web site design development 
  
  
  
Computer software development 
  
  
  
Software design and development

RE: [flexcoders] FB2B3 programmatically select an item in a ComboBox

2006-05-16 Thread Gordon Smith










The whole chain of what?



Storing the dataProvider, the loop limit,
and the data you're looking for in local vars WOULD be more efficient because
they remain the same throughout the loop and it is inefficient to evaluate them
over and over. But the item changes with each iteration so storing it in a
local var before accessing its data property is just an extra step.

var dp:Object
= cboCountry.dataProvider;
var n:int = dp.length;
var country:String = event.result.COUNTRY;

for (var i:int = 0; i  n ; i++)
{
 if (dp.getItemAt(i).data == country)
 {
  cboCountry.selectedIndex = i;
  break;
 }
}

- Gordon









From:
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of jeremy lu
Sent: Tuesday, May 16, 2006 3:00
AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] FB2B3
programmatically select an item in a ComboBox






hi Gordon, 

that's interesting, please bring it back here if you do get time to check it,
thanks :-)

btw, my rationale behind this is: player don't have to evaluate the whole chain
during the loop by assigning it to a variable, but I might just be wrong.






On 5/16/06, Gordon
Smith [EMAIL PROTECTED]
wrote:







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: flexcoders@yahoogroups.com
[mailto:
flexcoders@yahoogroups.com] On Behalf Of jeremy
lu
Sent: Monday, May 15, 2006 7:01 PM
To: flexcoders@yahoogroups.com
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!





Steve 











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.






simeon









On
5/15/06, Steve Gustafson [EMAIL PROTECTED]
wrote: 





Greetings and thanks in advance for your help!


I have a ComboBox that displays a countries.
 The label is a country Name
 The data is a country code

I then retrieve a users record via AMF. Standard stuff with First Name,
Last Name etc. 

I am populating various fields with the retrieved data, which is working fine.

Where I am stuck is on the country ComboBox. I want to select the
appropriate country for the user.

I expected something like this to work: 


for(var i:Number = 0; i  cboCountry.length; i++) 
{
 if(cboCountry.getItemAt(i).data ==
event.result.COUNTRY) 
 {
 cboCountry.selectedIndex = i;
 break;
 }
}

I have yet to figure out how to loop through the ComboBox to match the users
country. Or if I even need to run a loop in FB2B3.

This has got to be a very common task, yet I am not finding any decent info on
an approach. 

Any help is greatly appreciated.

Steve




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt

Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com






SPONSORED LINKS 




 
  
  Web site design development 
  
  
  Computer software development 
  
  
  Software design and development 
  
 
 
  
  Macromedia flex 
  
  
  Software development best practice 
  
  
  
  
 














YAHOO! GROUPS
LINKS 




 Visit your group 
 flexcoders on the web.
  
 To unsubscribe from this group, send an
 email to:
  [EMAIL PROTECTED] 
 
 Your use of Yahoo! Groups

[flexcoders] FB2B3 programmatically select an item in a ComboBox

2006-05-15 Thread Steve Gustafson



Greetings and thanks in advance for your help!I have a ComboBox that displays a countries. The label is a country Name The data is a country codeI then retrieve a users record via AMF. Standard stuff with First Name, Last Name etc.
I am populating various fields with the retrieved data, which is working fine.Where I am stuck is on the country ComboBox. I want to select the appropriate country for the user.I expected something like this to work:
for(var i:Number = 0; i  cboCountry.length; i++) { if(cboCountry.getItemAt(i).data == event.result.COUNTRY)  { cboCountry.selectedIndex = i; break; }
}I have yet to figure out how to loop through the ComboBox to match the users country. Or if I even need to run a loop in FB2B3.This has got to be a very common task, yet I am not finding any decent info on an approach.
Any help is greatly appreciated.Steve






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  









Re: [flexcoders] FB2B3 programmatically select an item in a ComboBox

2006-05-15 Thread Simeon Bateman



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.simeonOn 5/15/06, Steve Gustafson [EMAIL PROTECTED] wrote:



Greetings and thanks in advance for your help!I have a ComboBox that displays a countries. The label is a country Name The data is a country codeI then retrieve a users record via AMF. Standard stuff with First Name, Last Name etc.
I am populating various fields with the retrieved data, which is working fine.Where I am stuck is on the country ComboBox. I want to select the appropriate country for the user.I expected something like this to work:
for(var i:Number = 0; i  cboCountry.length; i++) { if(cboCountry.getItemAt(i).data == event.result.COUNTRY)  { cboCountry.selectedIndex = i; break; }

}I have yet to figure out how to loop through the ComboBox to match the users country. Or if I even need to run a loop in FB2B3.This has got to be a very common task, yet I am not finding any decent info on an approach.
Any help is greatly appreciated.Steve






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt

Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com









  
  
SPONSORED LINKS
  
  
  


Web site design development
  
  

Computer software development
  
  

Software design and development
  
  



Macromedia flex
  
  

Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group flexcoders on the web.

  To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
.



  















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



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  









Re: [flexcoders] FB2B3 programmatically select an item in a ComboBox

2006-05-15 Thread jeremy lu




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.simeonOn 5/15/06, Steve Gustafson
 [EMAIL PROTECTED] wrote:



Greetings and thanks in advance for your help!I have a ComboBox that displays a countries. The label is a country Name The data is a country codeI then retrieve a users record via AMF. Standard stuff with First Name, Last Name etc.
I am populating various fields with the retrieved data, which is working fine.Where I am stuck is on the country ComboBox. I want to select the appropriate country for the user.I expected something like this to work:
for(var i:Number = 0; i  cboCountry.length; i++) { if(cboCountry.getItemAt(i).data == event.result.COUNTRY)  { cboCountry.selectedIndex = i; break; }


}I
have yet to figure out how to loop through the ComboBox to match the
users country. Or if I even need to run a loop in FB2B3.This has got to be a very common task, yet I am not finding any decent info on an approach.
Any help is greatly appreciated.Steve






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt


Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com










  
  
SPONSORED LINKS
  
  
  



Web site design development
  
  


Computer software development
  
  


Software design and development
  
  




Macromedia flex
  
  


Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group flexcoders on the web.


  To unsubscribe from this group, send an email to:

[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service

.



  















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



  Visit your group flexcoders on the web.
  To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




  















--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  









Re: [flexcoders] FB2B3 programmatically select an item in a ComboBox

2006-05-15 Thread Steve Gustafson



That solved it! The key is using the dataProvider.length instead of the ComboBox .lengthI 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!Steve
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.simeonOn 5/15/06, Steve Gustafson
 [EMAIL PROTECTED] wrote:



Greetings and thanks in advance for your help!I have a ComboBox that displays a countries. The label is a country Name The data is a country codeI then retrieve a users record via AMF. Standard stuff with First Name, Last Name etc.
I am populating various fields with the retrieved data, which is working fine.Where I am stuck is on the country ComboBox. I want to select the appropriate country for the user.I expected something like this to work:
for(var i:Number = 0; i  cboCountry.length; i++) { if(cboCountry.getItemAt(i).data == event.result.COUNTRY)  { cboCountry.selectedIndex = i; break; }



}I
have yet to figure out how to loop through the ComboBox to match the
users country. Or if I even need to run a loop in FB2B3.This has got to be a very common task, yet I am not finding any decent info on an approach.
Any help is greatly appreciated.Steve






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt



Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com











  
  
SPONSORED LINKS
  
  
  




Web site design development
  
  



Computer software development
  
  



Software design and development
  
  





Macromedia flex
  
  



Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group flexcoders on the web.



  To unsubscribe from this group, send an email to:


[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service


.



  















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



  Visit your group flexcoders on the web.

  To unsubscribe from this group, send an email to:

[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
.




  















--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt

Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com









  
  
SPONSORED LINKS
  
  
  


Web site design development
  
  

Computer software development
  
  

Software design and development
  
  



Macromedia flex
  
  

Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group flexcoders on the web.

  To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
.



  















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



  Visit your group "flexcoders" on the web.
  To unsubscribe from this 

Re: [flexcoders] FB2B3 programmatically select an item in a ComboBox

2006-05-15 Thread jeremy lu




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 .lengthI 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!Steve

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.simeonOn 5/15/06, Steve Gustafson
 [EMAIL PROTECTED] wrote:



Greetings and thanks in advance for your help!I have a ComboBox that displays a countries. The label is a country Name The data is a country codeI then retrieve a users record via AMF. Standard stuff with First Name, Last Name etc.
I am populating various fields with the retrieved data, which is working fine.Where I am stuck is on the country ComboBox. I want to select the appropriate country for the user.I expected something like this to work:
for(var i:Number = 0; i  cboCountry.length; i++) { if(cboCountry.getItemAt(i).data == event.result.COUNTRY)  { cboCountry.selectedIndex = i; break; }




}I
have yet to figure out how to loop through the ComboBox to match the
users country. Or if I even need to run a loop in FB2B3.This has got to be a very common task, yet I am not finding any decent info on an approach.
Any help is greatly appreciated.Steve






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt




Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com












  
  
SPONSORED LINKS
  
  
  





Web site design development
  
  




Computer software development
  
  




Software design and development
  
  






Macromedia flex
  
  




Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group flexcoders on the web.




  To unsubscribe from this group, send an email to:



[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service



.



  















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



  Visit your group flexcoders on the web.


  To unsubscribe from this group, send an email to:


[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service

.




  















--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt


Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com










  
  
SPONSORED LINKS
  
  
  



Web site design development
  
  


Computer software development
  
  


Software design and development
  
  




Macromedia flex
  
  


Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group flexcoders on the web.


  To unsubscribe from this group, send an email to:

[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service

.



  















--
Flexcoders Mailing List
FAQ: 

RE: [flexcoders] FB2B3 programmatically select an item in a ComboBox

2006-05-15 Thread Gordon Smith










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:
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of jeremy lu
Sent: Monday, May 15, 2006 7:01 PM
To: flexcoders@yahoogroups.com
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!





Steve 












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.






simeon











On 5/15/06, Steve
Gustafson [EMAIL PROTECTED]
wrote: 





Greetings and thanks in
advance for your help!


I have a ComboBox that displays a countries.
 The label is a country Name
 The data is a country code

I then retrieve a users record via AMF. Standard stuff with First Name,
Last Name etc. 

I am populating various fields with the retrieved data, which is working fine.

Where I am stuck is on the country ComboBox. I want to select the
appropriate country for the user.

I expected something like this to work: 


for(var i:Number = 0; i  cboCountry.length; i++) 
{
 if(cboCountry.getItemAt(i).data == event.result.COUNTRY)

 {
 cboCountry.selectedIndex = i;
 break;
 }
}

I have yet to figure out how to loop through the ComboBox to match the users
country. Or if I even need to run a loop in FB2B3.

This has got to be a very common task, yet I am not finding any decent info on
an approach. 

Any help is greatly appreciated.

Steve




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com







SPONSORED
LINKS 




 
  
  Web site design development 
  
  
  Computer software development 
  
  
  Software design and development 
  
 
 
  
  Macromedia flex 
  
  
  Software development best practice 
  
  
  
  
 










YAHOO!
GROUPS LINKS





 Visit your group flexcoders
 on the web.
  
 To unsubscribe from this group, send an
 email to:
  [EMAIL PROTECTED]
 
 Your use of Yahoo! Groups is subject to the
 Yahoo! Terms of
 Service .



















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





 Visit your group flexcoders
 on the web.
  
 To unsubscribe from this group, send an
 email to:
  [EMAIL PROTECTED]
 
 Your use of Yahoo! Groups is subject to the
 Yahoo! Terms
 of Service .



















--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com







SPONSORED
LINKS 




 
  
  Web site design development 
  
  
  Computer software development 
  
  
  Software design and development 
  
 
 
  
  Macromedia flex 
  
  
  Software development best practice 
  
  
  
  
 










YAHOO!
GROUPS LINKS





 Visit your group flexcoders
 on the web.
  
 To unsubscribe from this group, send an
 email to:
  [EMAIL PROTECTED]
 
 Your use of Yahoo! Groups is subject to the
 Yahoo! Terms
 of Service