Forum Moderators: open
in the same frame, i created an empty movie clip
i am trying to load swf files into that movie clip by pressing the buttons located in the menu movie clip
the system works fine when i have the buttons on the same stage as the empty clip, but once the menu buttons are in their own movie clip i get an error
how can i tell a menu button located inside of a movie clip to load a swf into the empty movie clip using load movie?
my code:
on (release) {
loadMovie("movieToBeLoaded.swf", "emptyClip");
}
thanks!
On frame 2 (if the button clip is not on frame 1) create a seperate layer, name it actions, the write a function which firstly targets the buton, then issues it commands like this:
movieclipinstancename_mc.buttoninstancename_btn.onPress = function(){
emptyclip_mc.loadMovie("movieToBeLoaded.swf");
}
What you have done is drilled down to the button through its holding clip movieclipinstancename_mc.buttoninstancename_btn, and then told emptyclip_mc what to do (its on the root timeline so you can reference it directly)
One tip, good coding practice also says give movieclips instance names ending in _mc, buttons in _btn and dynamic text _txt, 1) flash then knows what it is, 2) it makes your code easier to read 3) when you come back to it in 6 months it will be much easier to understand/alter.
but it doesnt work for the drop down buttons...
the second button in this script refers to a button located in the drop down portion of the menu_mc
___________________________________________________
stop();
menu_mc.home_btn.onPress = function(){
empty_mc.loadMovie("weddingSiteNew_messageFromUs.swf");
}
menu_mc.weddingParty_btn.onPress = function(){
empty_mc.loadMovie("weddingSiteNew_weddingParty.swf");
}
____________________________________________________
do i need to keep the entire menu script within the same { }?
Second is this script on the main timeline, and what clips are these buttons embedded in?
1) try moving the stop() action to the end of all the scripts.
2) A stop() action at the end of the button holder clip should work?
3) Its really difficult to fix this without seeing the movie structure, is there anything beyond frame 2?
frame 1 is reserved for the preloader
frame 2 has the menu_mc and the empty_mc that i am loading the swf's into
the menu_mc has stop actions on the 1st frame and the "open" frame ("open" = when the drop down is activated)
i will try the stop @ the end of each command, i.e.
_________________________________________________
stop();
menu_mc.home_btn.onPress = function(){
empty_mc.loadMovie("weddingSiteNew_messageFromUs.swf");
}
stop();
menu_mc.weddingParty_btn.onPress = function(){
empty_mc.loadMovie("weddingSiteNew_weddingParty.swf");
}
stop();
__________________________________________________
etc...
EDIT:
the other buttons on the main stage are all working without the stop action
it is only the dropdown menu that doesnt work
plus, after i activate the dropdown action, the rest of the buttons that previously worked are broken
so there is a problem with the buttons in the dropdown menu calling to the empty_mc...i guess?
The problem I would guess is the buttons in the drop down do not exist when frame 2 is loaded (as I said before) as the menyclip is stopped at frame 1 (the buttons exist on frame 2 of that clip). Easiest is probably to move all the code relating to those buttons to an actions layer on frame 2 of the movieclip ie:
home_btn.onPress = function(){
_root.empty_mc.loadMovie("weddingSiteNew_messageFromUs.swf");
}
weddingParty_btn.onPress = function(){
_root.empty_mc.loadMovie("weddingSiteNew_weddingParty.swf");
}
etc etc
stop();
This is similar to before but here _root accesses the maintimeline (if by any chance _root does not work try _level0. instead (thats levelzero) instead.
Actionscript as a general rule can only affect items already on the timeline (yes I know there are exceptions) otherwise functions have nothing to reference.
is it possible to put the script on the dropdown buttons themselves using the _root. function?
it seems that putting the script on a seperate actions layer only works for the buttons existing on the same layer. once the script needs to reference the dropdown buttons (located inside the menu_mc on frame 2), it fails
Not at all, as I said the button must actually be on the stage otherwise the instance names mean nothing to the script.
Sticky mail me on this and I will see if I can sort it out.