PDA

View Full Version : how to use the ComboBox component


spiralelf
09-17-2002, 12:47 PM
Can someone please tell me how to use the ComboBox component in flash mx?

I have never used it before and would like to use it on my website - ambitious, I know. Even more ambitious is the fact that I'd like to link it to a database using either PHP or ASP (unfortunately I dont know any ColdFusion).

Can anyone please explain, or point me in the direction of a tutorial, that explains things to a beginner like me?


<thought>components in Flash mx are great, just with they came with instructions!</thought>

tg
09-17-2002, 03:17 PM
Originally posted by spiralelf

<thought>components in Flash mx are great, just with they came with instructions!</thought>

they do, check your flash reference panel.

for your question, do a couple tests to get used to using the component.


//create an array for labels
var arLabels=new Array("One","Two","Three");
//create an array for data
var arData=new Array(1,2,3);

/* put your combo box on the stage and give it an instance name
use 'test_cb' ... adding the _cb will trigger the actionscript
editor to popup the methods of the object... this will help you
as you get started
*/

// load the data
for(var i=0;i<arData.length;i++){
//actually load the label and data into the combo box
test_cb.addItem(arLabels[i],arData[i]);
}

/*you should now have a combobox filled with labels and data.
however you can't see the data, so lets do a test by clicking
an item in the combobox and doing a trace to see the data
*/

/*set your change handler for the combo box... this (the change
handler) tells the combo box what to do when the user clicks on
it.
*/
test_cb.setChangeHandler("onItemPicked");

//now write the function fired by the changehandler
onItemPicked=function("test_cb"){
//trace the data that was picked
trace(test_cb.getSelectedItem().data);
};


well... this kinda turned into a mini tutorial... sorry about that. this may or maynot work, as it was done on the fly.
however all the methods i used are in the documentation.
also, once you get this part working, and you understand whats going on, then run it all the same way, except instead of hadcoding your arrays for labels and data, look up the LoadVars() object, and read the values from a text file. once you got that down, then it will be time to learn some asp/php and how to use that technology to create the text file on the fly from a db.

good luck.


oh ya, there are lots of tuts out there on both php and asp for this kinda stuff, you just need to pick what you want to use and start searching.

spiralelf
09-19-2002, 09:05 AM
Hi tg

Thanks for telling me about the reference panel, I never knew that!

And thanks for your mini tutorial - I will be spending several hours working on your suggestions and trying to understand what is going on.

<quote>oh ya, there are lots of tuts out there on both php and asp for this kinda stuff, you just need to pick what you want to use and start searching.</quote>

Can you point me in the direction of a few good one? (preferably PHP)

Thanks, your help is greatly appreciated

-- spiralelf

Twister
04-11-2003, 06:47 PM
Please Help me too.

I've read the instructions and there is one thing that is bugging the hell out of me. Where is the selected items' data stored?!!!

Ok here is what i did.

I put a component on the stage and called it dropDown. Then filled it with Labels and Data in the properties window. Then i have a function called changeContent that is referenced by the ComboBox. The only problem is I don't know how to get the data of the item i selected.

Lable1 : New and Events
Data1: 10

Now in the function i want to do this:

_root.content.gotoAndStop(Data1) but I can't get it to work for the life of me. Ahhh. I just want to know where the data of the item i selected is stored!!!!!

freddycodes
04-11-2003, 07:23 PM
Originally posted by Twister
Please Help me too.

I've read the instructions and there is one thing that is bugging the hell out of me. Where is the selected items' data stored?!!!

Ok here is what i did.

I put a component on the stage and called it dropDown. Then filled it with Labels and Data in the properties window. Then i have a function called changeContent that is referenced by the ComboBox. The only problem is I don't know how to get the data of the item i selected.

Lable1 : New and Events
Data1: 10

Now in the function i want to do this:

_root.content.gotoAndStop(Data1) but I can't get it to work for the life of me. Ahhh. I just want to know where the data of the item i selected is stored!!!!!


You need to use getValue() its listed in the reference panel.


function changeContent(what)
{
gotoAndStop(what.getValue());
}

Twister
04-11-2003, 07:29 PM
Thanks for the help. I started back at square one and everything worked for once, Then i went into my big flash file and found two conflicting scripts. Why flash didn't tell me there was an issue is beyond me. OH well.

Thanks!