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 09-27-2007, 08:04 AM   #1
Holmqvist
Registered User
 
Join Date: Apr 2007
Posts: 28
Question ComboBox "addItem"-event..

Hi,

I've got a comboBox and I want to hide it if there is only one item in it.

I've tried to check it on the keyframe but that happens too soon, the comboBox won't be populated yet so length will always be 0. So I thought I'd check after an items been added (hide it on the first and show if there are more added after that), but I don't know any event that would work and my experiments have not been successful (nor google..)

Do you know how to do this with some event, or alternate solution?
Holmqvist is offline   Reply With Quote
Old 09-27-2007, 08:55 AM   #2
lsatdown
Senior Member
 
Join Date: Mar 2006
Posts: 427
Default

comboBox.addItem("item1");
comboBox.addItem("item1");
comboBox.addItem("item1");
comboBox.addItem("item1");
comboBox.addItem("item1");
if(comboBox.length = 1) {
comboBox._visible = false;
comboBox._enabled = false;
}
else {
comboBox._visible = true;
comboBox._enabled = true
};
lsatdown is offline   Reply With Quote
Old 09-27-2007, 08:56 AM   #3
lsatdown
Senior Member
 
Join Date: Mar 2006
Posts: 427
Default

or:
Quote:
comboBox.addItem("item1");
comboBox.addItem("item1");
comboBox.addItem("item1");
comboBox.addItem("item1");
comboBox.addItem("item1");
onEnterFrame = function() {
if(comboBox.length = 1) {
comboBox._visible = false;
comboBox._enabled = false;
}
else {
comboBox._visible = true;
comboBox._enabled = true
}
}
lsatdown is offline   Reply With Quote
Old 09-27-2007, 02:07 PM   #4
Holmqvist
Registered User
 
Join Date: Apr 2007
Posts: 28
Default

Well I guess the onEnterFrame one would work.. but I'm not too excited about using it. Got another solution that doesn't keep chewing resources when I'm done?

I add all items at one time, but it seems that if i hide it when I add something, it will become visible when the item is loaded in anyway, so I need to hide it when it's done, after the items been added. Or if there's some other way to go around it.
Holmqvist is offline   Reply With Quote
Old 09-27-2007, 04:11 PM   #5
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

you could put all items you want to use in an array. if the length of the array > 1 then attach a combobox and use the array as the dataProvider, if it is not, then show your item however you have planned
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 09-28-2007, 02:30 PM   #6
Holmqvist
Registered User
 
Join Date: Apr 2007
Posts: 28
Default

Yea, that's a good solution but I think I need to add the combobox any case, cause i read the selected value on clicks to see if it's changed... so that would cause some trouble to me I'm not ready to deal with.
Holmqvist 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
creating separate classes for custom event frank grimes ActionScript 3.0 6 06-27-2009 10:55 PM
Combobox "change" event and focus bug? Gremzicus Components 2 11-16-2007 08:06 PM
Put parameters in a function called by the "change" event of a combobox emilie_t Components 2 07-05-2007 10:09 PM
ComboBox and event handlers krivedal Components 2 12-09-2006 01:18 PM
Event handling with Listeners - learning from Java robertpenner ActionScript 1.0 (and below) 2 08-08-2001 11:36 PM


All times are GMT. The time now is 12:48 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.