Combo box with mc/jpg

Hi,

I’m looking for a way to get each item of a combobox/ listbox load a actionscript. For example, i’ve have a scrolling family tree with over a hundred names in them. So I’d like to create a listbox or combox with all those names. Now when one selects a name it will movie the family tree to that name. I looked at kirupa’s tutorial but it’s for dynamic text input.

if you guys have any idea let me know. j

There’s a tute about a combobox (or a listbox, I don’t remember) that shows how to use associated data. Check it.

pom :asian:

Thank You,
but unfotunately it only describes how to load dynamic text with the listbox. I need to now how to loadMovie from the listbox. I’m a little stuck. Thanks for your help. J

What do you mean? And are we talking about this tutorial: http://www.kirupa.com/developer/mx/listbox.asp ?

Now when one selects a name it will movie the family tree to that name
I don’t understand what you mean by that, but I’m sure that if you get the name that is selected, you can do whatever you want with it, no?

pom :asian:

I’ve looked at that tutorial several times but I cannot figure out how to replace the code. This tutorial specifically talks about how you can load dynamic text when a item in the listbox is selected. However I cannot firgure out how to change that to run a “loadmovie” script. thanks though. J

*Originally posted by sevensleeper *
This tutorial specifically talks about how you can load dynamic text when a item in the listbox is selected.
No, it does not specifically talk about that, it gives an example of how you can use the data in this component. And we’re not loading anything in the tutorial…

What you have to do is:[list][]Instead of storing a date like in the tutorial, you store the movie you have to load (that way it is associated to the person you want[]you create a custom function that will load the corresponding movie when you click on an element of the listbox[/list]
For instance, if your listbox is called list, you could have something like this:

list.addItem("me", new Array("movie1.swf"));
list.addItem("you",new Array("movie2.swf"));
list.addItem("he",new Array("movie3.swf"));
list.addItem("she",new Array("movie4.swf"));
list.addItem("them",new Array("movie5.swf"));

function loadMyMovie(c){
	var j = c.getSelectedItem().data;
	loadMovieNum(j,1);
}

list.setChangeHandler("loadMyMovie");

pom :asian:

I’m not the actionscript expert so changing the function in the script was beyond me. But I I understand it right now. Thank You. J

Thank You for explaining it. works like a charm… but I think I get the idiot award today. I have need the list items to dothis:

on (press) {
_root.zoomMC.mapMC.tX=_root.zoomMC.mapMC.tY=0;_root.zoomMC.tzoom=100;}

on (release) {
_root.zoomMC.mapMC.tX=56;_root.zoomMC.mapMC.tY=46;_root.zoomMC.tzoom=300;
}

Basically I want my family tree move to the corosponding name when pressed in the listbox. The zoomMC has this code:

onClipEvent (load) {
tzoom=100;speed=0.2;tzoomc=0;
}
onClipEvent (enterFrame) {
tzoom+=tzoomc;
_xscale=_yscale=_yscale+speed*(tzoom-_yscale);
}

and the mapMC has this:
onClipEvent (load) {
tX=0; tY=0;speed=0.2;ctX=0;ctY=0;
}
onClipEvent (enterFrame) {
tX+=ctX;tY+=ctY;
_x=_x+speed*(tX-_x);_y=_y+speed*(tY-_y);
}

Sorry for buggin you. Maybe I need to use a different way to move and zoom my familytree? Thankyou agin though for the help. j