PDA

View Full Version : ComboBox Change Handler doesn't work -- proj needs to be done soon!


ninjapheret
08-24-2004, 08:33 PM
Hi guys,

I've had this posted three times in the AS forum here, but no luck there...if anyone could please council me with this I would be extremely grateful. This needs to be done before the 4th of September..

I've got a project wherein a ComboBox (called nameBox) has a list of people's names, and according data (their addreses). I have a dynamic textbox called "inscription" which should display the data of whatever value is currently selected in "nameBox".

Problem is my change handler doesn't work! It's a simple line in the change handler of the ComboBox:

inscription.text = theData;

with the following code on frame 1:

var theData = nameBox.selectedItem.data;

I had also tried putting the following line on the change handler with no luck:

inscription.text = this.selectedItem.data;

Why wouldn't such a simple thing work?

Again, I will really appreciate some help. If I can help you with anything let me know.

bobk101060
08-24-2004, 08:40 PM
I am no whiz at Actionscript (yet), but I have used the combobox and this is what I did.

First off, you have to add a listener to the change event of your combobox. This way when the user clicks on one of the items in the drop down, it will fire off a change event to anyone that is listening. Inside the change listener is where you put your code to move in the selected name. Here is a brief code snippet depicting what I am refering to:

//
var myListener = new Object();

bobk101060
08-24-2004, 08:46 PM
Sorry, Hit the post button inadvertently. Here is the rest of the code:

// Define the listener object.
var myListener = new Object();

// Define the Event Handler that will be kicked off when the user clicks on a name in
// the combobox drop down list.
myListener.change = function(myObj) {
// Move in the selected name to your text field.
inscription.text = myObj.target.value;
}

// Add the listener to the combobox.
nameBox.addEventListener("change",myListener);

This should do it. Try it and let me know how you make out.

ninjapheret
08-24-2004, 08:48 PM
nope didn't do anything..I'll post the fla in a minute.

ninjapheret
08-24-2004, 09:13 PM
http://www.petrafineart.com/presentation/donors.fla

there ya go...

ninjapheret
08-26-2004, 08:51 PM
posted the flash....does anyone know whats wrong with this thing? i'll owe you HUGE this has to be done so rediculously soon that i'm getting scared.

ninjapheret
08-26-2004, 10:40 PM
I'm begging you -- anyone -- i'll send you 5 dollars ;)

bobk101060
08-27-2004, 12:27 PM
What version of Flash are you running? Also, it appears that you are using the Flash MX UI Components as opposed to just the UI components. I do not have any faith in the components you are using. I would try and buiild your movie using the "UI Components" and stay away from the Flash MX UI Components.

ninjapheret
08-27-2004, 06:59 PM
Whats wrong with "mx" components? Since the only editor i have is Flash MX i can't really use anything else, can i?


Edit: When I look at my component library, it says "Flash UI Components" and nothing else...not MX Components or anything.