Groups | Blog | Home
all groups > flash actionscript > july 2006 >

flash actionscript : How can i use the combobox to load a symbol from library


fanmap81
7/1/2006 6:50:01 PM
I want to use the combobox named myCombo to load different symbols onto the
stage according to whatever choice is selected. I got linkage ids on the
symbols in the library (symbol1,symbol2,symbol3), but im not sure where to go
from here. Can someone help me out?
fanmap81
7/2/2006 6:48:04 PM
kglad
7/2/2006 7:55:27 PM
first you must assign linkage ids to your library movieclips that you wish to
"bring" to the stage (or instantiate). you will not be loading them. you must
use attachMovie() to instantiate a movieclip that's in your library.

if you have a combobox with instance name cb and movieclips with linkage ids
mcgray, mcgreen and mcred, you can use the following to have your combobox
instantiate those movieclips:



cb.addItem({label:"red", data:"mcred"});
cb.addItem({label:"gray", data:"mcgray"});
cb.addItem({label:"green", data:"mcgreen"});
dep = 0;
lo = new Object();
lo.change = function(eventObject:Object) {
_root.attachMovie(cb.value, cb.value, dep);
dep++;
};
cb.addEventListener("change", lo);
AddThis Social Bookmark Button