Hey guys, I am embarrassed to say I don't know how to use a ComboBox. I'm setting up a form with about 8 ComboBoxes. Based on the answers a _mc will load. Can anyone please help me with this? I have the layout and the info all in,I just need to learn how to make it work.
Well, for starters you can use myComboBox.getValue() to find out what your user has selected. From there, you can write if/then statements based on what the user has selected. That's pretty general - is that the sort of answer you're looking for? If not, give me more details, and I'll try to help.
Oh, and you'll probably want to create a change handler function for your combo box - that's a function that gets called whenever something is changed in your combo box, such as when the user selects something. Holler if you need more details about this.
Thanks so much. Here is the file. Basically it is seven questions and based on the answers, a different _mc will load. I dont know how to even begin coding this. I know a decent amount of flash but have never had to use a CoboBox yet. I feel like such a rookie Here is the file. any pointers are appreciated.
hahaha thanks, with my design prowess and your form building we could take over the world!!!! Or maybe just work regular jobs and pay bills but whatever
The first thing you need to do is give your combo boxes and your button instance names. You can do that by clicking on the combo box or button, and then opening the Properties panel. (In the top left of the panel, you'll see the box where you enter the instance name.)
After you do that, add another layer and name it Actions. From this layer, open the Actions panel. This is where you're going to put all of the actionscript that will keep track of what's been selected in the combo boxes, and what will happen when your user clicks the Submit button. You'll want to be in Expert mode so you can just type in the actionscript directly. If you don't know how to switch from Normal mode to Expert mode, let me know...
Now create some variables that will keep track of what has been selected in each combo box. Type this in your Actions panel:
Code:
var varComboBox1 = myComboBox1.getValue();
myComboBox1 is the instance name you created for your first combo box. varComboBox1 can named differently if you want. Keep doing this for all of the combo boxes.
myComboBox1.getValue() will return the label of the item selected in the combox box. So in your example, if the user selected New Business in the first combo box, varComboBox1 would be "New Business".
Now for the part that happens when the user presses Submit. Type something like this in the Actions panel:
Code:
if (varComboBox1=="New Business") {
loadMovie("url",level/target[, variables]);
}
Of course, I don't know which movies you want to load when the user selects various combinations. Your if/then statements could get pretty ugly depending on how many movies you have to choose between. Holler if you want help with that part.
I hope at least some of this makes sense, but I just had cheetos and coffee for lunch and my ability to communicate may have been affected for the worse. Let me know if I've confused you, and we'll get it figured out.
Man, I'm sorry to keep bothering you... I realy thought this would be the time I got it right. Ok here is my code on frame one.
Code:
stop();
var varComboBox1 = myComboBox1.getValue();
and this is the code on my button
Code:
on (release){
if(varComboBox1 == "New Business")
loadMovie("text_files/documents_MOVIE.swf", "right");
}
The ComboBox instance name is "myComboBox1". this is the set-up that is not working. I've tried a bunch of different version and basically the problem seems to be with the ComboBox. The button code works fine once I take the "if" statement off. and I used similar code before. should I be doing ANYTHING else? I don't have a change handler set up, is that an issue? Also I don't have anything set up as "DATA" in the ComboBox. Thank you so much for helping me through this.
Oops! My fault. Of course you need a change handler function for the combo box - otherwise how will it update varComboBox1 when the user selects something there? So make myComboBox1 have the change handler myComboBox1Change, and this should work:
Code:
var varComboBox1;
function myComboBox1Change() {
varComboBox1 = myComboBox1.getValue();
}
stop();
(Leave the code for your button as is.)
BTW, when you don't have anything for DATA in the comboBox, .getValue() just returns the label, so that shouldn't be a problem.
And yes, I'm on MSN, but no, I can't use it at work (grrrr!) so flashkit is the best way to reach me. Don't worry about bothering me - after a hard day of not understanding ANYTHING else I'm working on, it's a nice ego boost to help someone with the couple of things I do know how to do. Mostly know. Sort of know. Can eventually figure out, anyway.
PERFECT!!! Now on to the IF scripts. I can handle that on my own though. Thanks so much. A JAVA developer here came over to help me out and he had it pretty much nailed but way too complicated
Basically, putting the comboBox in a movie clip just changes its path. So assuming your comboBox change handler isn't created in the movie clip, it will have to look like this:
Code:
function myComboBox1Change() {
varComboBox1 = _root.myMovieClip.myComboBox1.getValue();
}
myLoadVars = new LoadVars();
varComboBox1 = myLoadVars.varComboBox1;
myLoadVars.sendAndLoad("Some_ASP_Page.asp",myLoadVars,"POST");
This sends the variable in MIME format, e.g., varComboBox1=this&varComboBox2=thatr&varComboBox3= theother
I suggest using myLoadVars.sendAndLoad rather than myLoadVars.send. This is because myLoadVars.send will cause the asp page to open too, and be visible to the user. That's probably not what you want. The only way I've found to avoid this is to use myLoadVars.sendAndLoad.
Ok, here is the code I currently have on frame one
Code:
var varcomboBox1;
function comboBox1Change() {
varcomboBox1 = comboBox1.getValue();
}
var varcomboBox2;
function comboBox2Change() {
varcomboBox2 = comboBox2.getValue();
}
var varcomboBox3;
function comboBox3Change() {
varcomboBox3 = comboBox3.getValue();
}
var varcomboBox4;
function comboBox4Change() {
varcomboBox4 = comboBox4.getValue();
}
var varcomboBox5;
function comboBox5Change() {
varcomboBox5 = comboBox5.getValue();
}
var varcomboBox6;
function comboBox6Change() {
varcomboBox6 = comboBox6.getValue();
}
var varcomboBox7;
function comboBox7Change() {
varcomboBox7 = comboBox7.getValue();
}
stop();