PDA

View Full Version : ComboBox code to open external swf in movie clip


yomsbea
09-20-2007, 01:11 AM
:p
Hi everybody,
A total newbie here looking for the following knowledge:
I want to use the ComboBox component to open an external swf file in a movie clip (or in level 2 if too complicated), what im woking on is a store locator where each state in the comboBox menu will open an external swf with the list of stores related to that particular state.

Any help with this code will be appreciated.

Note:
I Looked throu the postings here and found this post from bembino in 2003:
------------------------------------------------------------------------
Place a combobox on frame 1 of the main timeline
Name it externalSWF_cb
Select frame 1 of the main timeline and open the Actions Panel
Type the following code:
// create array of label and data info for combobox
externalSWF_array = [ {label:"Fade JPG", data:"fadeJPG.swf"}, {label:"Load Big JPG", data:"loadBigJPG.swf"}];
// populate combobox with data from array
externalSWF_cb.setDataProvider(externalSWF_array);
// define changeHandler for combobox
function onExtSWFSelected(cb) {
loadMovieNum(cb.getSelectedItem().data, 2);
}
//assign changeHandler to combobox
externalSWF_cb.setChangeHandler("onExtSWFSelected");
Of course, you would change the externalSWF_array to match your file names.
----------------------------------------------------------------------
List menu on comboBox work just fine but didn't open any of the external swfs.

I'm not a programmer so a code to do this and where to place it will be very helpful.

Thanks a lot, you guys rock!

YMB

tg
09-20-2007, 03:10 PM
ok. so using the example you posted, try this (once you get it working implement it on your project):
1..create a new blank flash project
2..put a combo box on the stage
3..select combo box, and in properties panel give it an instance name of 'externalSWF_cb'
4..deselect the combo box and open your actionscript panel
5..copy and paste the above code into the actionscript panel
6..create a movieclip and place it on your stage (or create one via actionscript)
7..give your movieclip an instance name 'mcLoader'
8..change the following code:

//old code
function onExtSWFSelected(cb) {
loadMovieNum(cb.getSelectedItem().data, 2);
}
//new code
function onExtSWFSelected(cb) {
mcLoader.loadMovie(cb.getSelectedItem().data);
}



hrm.... it has been a terribly long time since i have done something like this, but i believe that is the correct syntax for loading a swf into a movieclip.


try it, see what happens. and welcome to as[org]

yomsbea
09-21-2007, 01:29 AM
Hi tg,
thanks for your help.

I tried but didn't work, i wonder what the location of those external swf should be. So far i placed them in the same folder with the main movie.

Any other thoughts?

YMB

tg
09-21-2007, 04:04 PM
well. are you just running it in test mode? if you're tesing it from a web page, they need to be relative to the page the swf is embedded in, no the actual swf itself.

yomsbea
09-21-2007, 09:37 PM
Hi tg,
I'm still running it on my local disk and still failing to open the external swf on the mcloader.

Not quite sure what the problem is since i'm not a programmer.

any other idea?

YMB

quocdai
10-29-2008, 01:58 AM
ok,thanh you.i need it