Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Reply
 
Thread Tools Rate Thread Display Modes
Old 10-26-2009, 12:14 PM   #1
theMonitor
Member
 
Join Date: Mar 2003
Posts: 62
Default [AS2] Problem selecting first value in combobox

I'm using a combobox component that I'm populating with a five-element array, as follows:

0 All
1 Bakery
2 Diary
3 Deli
4 Drink

And because I don't want "All" displaying in the text box, I've added the line

dropDown.text = "Select here..."

once the combobox is populated. Unfortunately, when I test the combobox and open the list, "All" is at the top of the list but already selected, so that when I click it, nothing happens. The rest of the items work fine.

Could someone tell me how to disable the first item, so that it's not automatically selected when the list opens and therefore can be clicked?
theMonitor is offline   Reply With Quote
Old 10-26-2009, 04:10 PM   #2
galak
Senior Member
 
Join Date: Mar 2005
Posts: 439
Default

why don't you just add a first item that is the "select an item" text, with no data. and in your listener function you tell it not to do anything if there's no data.

so your drop down would be populated as such :

0 Select an item
1 All
2 Bakery
3 Diary
4 Deli
5 Drink
galak is offline   Reply With Quote
Old 10-26-2009, 04:50 PM   #3
theMonitor
Member
 
Join Date: Mar 2003
Posts: 62
Default

The problem then (unless I've mis-read your instructions) is that "Select an item..." appears not just in the text box when the combobox is unopened, but also at the top of the drop-down list. I know it sounds a bit nit-picky, but what I really wanted was a title that didn't show up twice.

Sorry if I didn't explain myself very clearly.
theMonitor is offline   Reply With Quote
Old 10-27-2009, 01:01 AM   #4
galak
Senior Member
 
Join Date: Mar 2005
Posts: 439
Default

Ok then, why don't you add a listener on the "close" event, instead or even along with the "change" event, in that case even if you click on an already selected item, which is the case for the first one, it will return the value.

If you don't want the event to trigger again on close afterwards, just put a condiiton in it that disables or deletes the "close" event once a "change" has occurred.
galak is offline   Reply With Quote
Old 10-27-2009, 09:52 AM   #5
theMonitor
Member
 
Join Date: Mar 2003
Posts: 62
Default

Good idea. In the end what I did was just listen for the 'close' event instead of the 'change ' event, which seems to do the trick.

Thanks for your advice.
theMonitor is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:37 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.