Forum Moderators: open

Message Too Old, No Replies

load movie

loading movie from inside another movie

         

jeremymack

1:12 am on Nov 7, 2005 (gmt 0)

10+ Year Member



i have my navigation menu in a movie clip on frame 2 of the main timeline

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!

Richard_N

8:27 am on Nov 7, 2005 (gmt 0)



good practice is to put all the code on the main timeline, keeps movies tidy and easier to understand

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.

jeremymack

3:52 pm on Nov 7, 2005 (gmt 0)

10+ Year Member



i see...i should put the actionscript on the frame itself, rather than on each button...

thanks, i will try it and let you know!

jeremymack

6:49 pm on Nov 7, 2005 (gmt 0)

10+ Year Member



it works

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 { }?

Richard_N

9:22 pm on Nov 7, 2005 (gmt 0)



Ok first, what does the stop()action refer to?

Second is this script on the main timeline, and what clips are these buttons embedded in?

jeremymack

9:33 pm on Nov 7, 2005 (gmt 0)

10+ Year Member



the stop is to prevent the menu_mc from repeating...i put a stop in the menu_mc, but it doesnt affect it

on the main timeline, i have 2 layers:
1. the script is on the main timeline, in the actions layer
2. the empty_mc and the menu_mc are in layer 1

the buttons are in the menu_mc

Richard_N

9:59 pm on Nov 7, 2005 (gmt 0)



OK I would guess the problem may be that the buttons (which I guess are in a drop down portion of the menu) may not actually exist when you actually run frame 2 of the main timeline so the actionscript will not pick them up.

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?

jeremymack

10:07 pm on Nov 7, 2005 (gmt 0)

10+ Year Member



there is nothing 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?

Richard_N

11:17 pm on Nov 7, 2005 (gmt 0)



certainly you do not need the stop action after every function... although you will need one at the end of the movie (frame 2).

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.

jeremymack

11:31 pm on Nov 7, 2005 (gmt 0)

10+ Year Member



yes i tried the _root. function, and it didnt solve the problem

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

Richard_N

7:54 am on Nov 8, 2005 (gmt 0)



<quote>It seems that putting the script on a seperate actions layer only works for the buttons existing on the same layer</quote>

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.