Hi,
I don't have much time to explain in detail, so I will show you a code sample of a previous project I created that employs 2 combobox components to make a selection. If you place two combobox's on the stage in a test movie with instance names of "c1" and "c2" and paste this code onto the first keyframe of the main timeline, it should give you an idea of where to proceed and how to adapt the code to your individual project...
Code:
//arrays are extremely useful so lets get used to using them to store data...
//in this case, the names of the movies we want to load...
myMovies = ["movie1.swf", "movie2.swf", "movie3.swf", "movie4.swf", "movie5.swf"];
//create a listener object
LO = new Object();
//assign a value to a variable for each cbox using the change class
LO.change = function(EO) {
c1Value = c1.getSelectedItem().label;
c2Value = c2.getSelectedItem().label;
//call the checkValue function
checkValue();
}
function c1Init() {
c1.addItem({data:0, label:"Home"});
c1.addItem({data:1, label:"Info"});
c1.addItem({data:2, label:"Contact"});
c1Value = c1.getSelectedItem().label;
c2.addItem({data:0, label:"Make a Selection"});
c2.addItem({data:1, label:"Home Label2"});
c2.addItem({data:2, label:"Home Label3"});
}
c1Init();
checkValue();
//standard function using a switch statement to
//check the value of a userChoice1 variable and
//power the project...replace trace statements with
//whatever functionality you want
function checkValue() {
userChoice1 = c1Value;
userChoice2 = c2Value;
switch (userChoice1) {
case "Home" :
//clear cbox2
c2.removeAll();
//set home labels for cbox 2
c2.addItem({data:0, label:"Make a Selection"});
c2.addItem({data:1, label:"Home Label2"});
c2.addItem({data:2, label:"Home Label3"});
break;
case "Info" :
//clear cbox2
c2.removeAll();
//set info labels for cbox 2
c2.addItem({data:0, label:"Make a Selection"});
c2.addItem({data:1, label:"Info Label2"});
c2.addItem({data:2, label:"Info Label3"});
break;
case "Contact" :
//clear cbox2
c2.removeAll();
//set contact labels for cbox 2
c2.addItem({data:0, label:"Make a Selection"});
c2.addItem({data:1, label:"Contact Label2"});
c2.addItem({data:2, label:"Contact Label3"});
break;
default :
//trace("Invalid Selection");
break;
}
switch (userChoice2) {
case "Home Label2" :
trace("Load movie A");
myMC.loadMovie(myMovies[0]);
break;
case "Home Label3" :
trace("Load movie B");
myMC.loadMovie(myMovies[1]);
break;
case "Info Label2" :
trace("Load movie C");
myMC.loadMovie(myMovies[2]);
break;
case "Info Label3" :
trace("Load movie D");
myMC.loadMovie(myMovies[3]);
break;
case "Contact Label2" :
trace("Load movie E");
myMC.loadMovie(myMovies[4]);
break;
case "Contact Label3" :
trace("Load movie F");
myMC.loadMovie(myMovies[5]);
break;
default :
//trace("Invalid Selection");
break;
}
}
//using a simple for loop to assign the listener object to both combobox's
//you can write a lister for each component but it's not really necessary
//for this situation...
for (i=1; i<3; ++i) {
_root["c"+i].addEventListener("change", LO);
}
The above is designed to load movies depending on the users choice selection from two different comboboxes. While similar to your description, it is not exact and will need some fine tuning to be applied to your situation. The content for the comboboxes are all coded in AS and are not author time labels but this is just semantics and will work either way.
hope it helps
Regards
NTD
Bookmarks