Forum Moderators: open

Message Too Old, No Replies

Dealing with comboboxes

         

alce

5:43 pm on Jun 7, 2006 (gmt 0)

10+ Year Member



These are my very first steps with Actionscript. Any suggestions would be greatly appreciated.

I have 2 comboboxes. One for years and one for months. The values for both are set at runtime depending on the current date. I have 2 questions:

1. What is the equivalnet to HTML's selected="selected"?. I want to display the current month & year as the selected option in the combobox when it is first loaded.

2. The comboboxes are used load external swf's upon request. I am able to load the swf's using a change event listener on the month's combobox, however, this does not take into consideration the value of the years combobox. How can I get both values and load the correspinding swf?

this is what I have so far:

createEmptyMovieClip('holder_mc', 1);

//create & register event listener for the months combo
listen = new Object();
listen.change = function(evt) {
holder_mc.loadMovie(months_cb.value);
};
months_cb.addEventListener('change', listen);

Obviously this code completely disregards wich year was selected, so I tried something like this but it does not work (maybe some variable scope problem?)

//create & register change event listener for the year combobox

listen2 = new Object();
listen2.change = function(evt) {
var selected_year:Number = years_cb.value;
return selected_year;
};
years_cb.addEventListener('change', listen2);

What I am trying to do is to get the value of the year combobox to be used along with the value of the month box and then load the swf accordingly:

//create & register event listener for the months combo
listen = new Object();
listen.change = function(evt) {
holder_mc.loadMovie(selected_year + months_cb.value);
};
months_cb.addEventListener('change', listen);

I KNOW I am going around in cicles. Any pointers?