Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

flash mx 2004 combobox component

Status
Not open for further replies.

riwer

Technical User
May 30, 2004
21
BA
Hello

I'm Farley new to flash and don't have much experience with action scripts
and I got stuck on trivial thing. I would like to use combobox component to
group few links, nothing complicated - click on combobox select label, go to
page.

Now I was digging around the internet and didn't find anything simple
(everything involves xml, dynamically adding/removing slots and so on :)

So if anyone can help me or put me in the right direction I would be most
grateful.



Riwer
 
You just need to add an event listener to the combobox.

Here is an example. Drag a combobox the stage and give the instance name "myCombo". Go to the properties panel and add labels and data (1 data for every label).

Add a new layer and title it "actionscript". On the first frame of the second layer add the following actionscript:

Code:
myListener = new Object();
myListener.change = function(component){
    trace("The selected label is "+ component.target.text);
    trace("The selected data value is=" + component.target.value);
}

myCombo.addEventListener("change",myListener);

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
So how would you then take that data (or Label) and use it as a variable so it could be sent using loadVariables?
 
Set the variable value in the function above. Example:
Code:
myListener = new Object();
myListener.change = function(component){
    trace("The selected label is "+ component.target.text);
    trace("The selected data value is=" + component.target.value);
//set the variable
_global.selectedValue = component.target.value;
}

myCombo.addEventListener("change",myListener);

Then you loadVariables would be something like this.
Code:
on(release){
    comboValue = _global.selectedValue;
    loadVariables("scriptName.asp",POST);
}

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Please forgive my ignorance... I still don't think the combobox is sending the variable to my script. I'm just going to c/p the whole thing if you wouldn't mind taking a look. The instance name on the combobox is userContactType1 and the variable for it is userContactType. The other variables if needed have the instance name tName, tAddress, etc. and the variable userName, userAddress, etc. status is a variable the form sends back that says either "Mail Sent" or "Required values not found". Also, does it matter whether I use _global or say _level0 on the combobox? Thanks a ton for any help!
Code:
//ComboBox style
_global.style.setStyle("themeColor", "haloOrange");
userContactType1.setStyle("selectionColor", 0xCCCCCC);
userContactType1.setStyle("rollOverColor", 0xE7E7E7);
userContactType1.setStyle("color", 0x000000);
userContactType1.setStyle("openEasing", mx.transitions.easing.Elastic.easeOut); 
userContactType1.setStyle("openDuration", 1000);


//Datatyping variables
var btnTransfer:Button;
var btnClear:Button;
var btnContacts:Button;
var contactresult:LoadVars = new LoadVars();
var userContactType:Object = userContactType1.selectedItem.data;
var status:String;

//_level0.userContactType = component.target.value;
myListener = new Object();
myListener.change = function(component){
    //trace("The selected label is "+ component.target.text);
    //trace("The selected data value is " + component.target.value);
	//trace(userContactType);
	_global.selectedValue = component.target.value;
}
userContactType1.addEventListener("change",myListener);


//change email addy to all lowercase, check TextFields/ComboBox for completion, send form
btnTransfer.onRelease = function(){
	userEmail.text = userEmail.text.toLowerCase();
	if(tName.text.length == 0 ||
		tEmail.text.length == 0 ||
		userContactType1.selectedItem.data == "Please Select" ||
		tComments.text.length == 0){
	   	gotoAndStop("error");
	}else{
			userContactType = _global.selectedValue;
			loadVariables("[URL unfurl="true"]http://www.MYURL.com/05/tech-support/contact/contactreq.cfm",[/URL] contactresult, "POST");
			gotoAndStop("sent");
			tComments.text = status;
		}
}


//Set "Clear Form" Button to clear text fields
btnClear.onRelease = function(){
	userName = ""
	userAddress = ""
	userCity = ""
	userState = ""
	userZip = ""
	userCountry = ""
	userPhone = ""
	userEmail = ""
	userURL = ""
	userContactType1.setSelectedIndex(0);
	userComments = "Comments..."
	gotoAndStop("form")
}

//Set phone button to bring up phone contact info
btnContacts.onRelease = function(){
	gotoAndStop("contacts");

}
 
Can you zip and post the whole .fla? From what I can see in what you posted it should be working.
 
Thanks anyway pixl8r...
I've got it figured out. The way my .cfm file was accepting the variables had to be changed. It works now. So you were right, it should and does work.
Thanks again for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top