PDA

View Full Version : MC loading external swf


krone
06-15-2005, 12:27 PM
hello this is a pretty simple question really

i have an MC on my main timeline. and i want it to load an external swf when the main SWF is started.

the below doesnt work

onClipEvent(load) {
_root.holder.loadMovie("01.swf");
}


cheerio.. :)

beadyen
06-15-2005, 12:38 PM
Check _root.holder is the correct target & check that "01.swf" exists... failing that it seems odd that it wouldn't work. What else is going on in your movie?

krone
06-15-2005, 01:08 PM
the maintimeline (index) holds buttons and each button triggers a different page to load into holder (empty MC)

but i want (when u load up index) that the empty MC be already holding 01.swf.. and of course if u click on the buttons u can go to 02, 03, 04 or back to 01.

ive checked everything and with that code the empty MC remains empty but also none of the other buttons work.

ive implemented the code on the Empty MC on the maintimeline. should it perhaps be somewhere else? or something? hehe i dono..

beadyen
06-15-2005, 01:23 PM
I tend to put code on frames rather than movieclips, it's a lot easier to follow.
Check if your external swfs are loading at all by using getBytesTotal():


// on a frame on you main timeline
_root.holder.loadMovie("01.swf");
_root.onEnterFrame = function() {
trace("total bytes = " + _root.holder.getBytesTotal());
trace("loaded bytes = " + _root.holder.getBytesLoaded());
}


that should tell you if the files are loading and eliminate one problem at least.
If they are loading OK it could be some other problem like the visibility of your holder mc, or what frames your different movies/buttons are on.

I'm off to bed (it's 1.20AM where I am :) ) so good luck with it, will check back tomorrow.

zer0ruth
06-15-2005, 09:36 PM
This might be a little easier

If you don't have an "actions" layer already, create a new layer and name it actions and then in the blank key frame insert the following actionScript


_root.onLoad = function() { //this loads the 1.swf as soon as the movie loads
loadMovie("1.swf", _root.holder); // the second parameter: _root.holder sets where 1.swf will be loaded, in this case a movie clip on the main timeline named holder
};

// these control three buttons on the main stage, they load movie 1 through three respectivly into the holder movieClip
_root.button1.onPress = function() {
loadMovie("1.swf", _root.holder);
};
_root.button2.onPress = function() {
loadMovie("2.swf", _root.holder);
};
_root.button3.onPress = function() {
loadMovie("3.swf", _root.holder);
};




Now just create a button and put three instances on the main stage and name them "button1, "button2", and "button3"

and last but not least create a blank movie clip and name it "holder" Keep in mind that the x and y postions of this movie clip is where your external swf's will be loaded.

This way is a lot more expandable. Hope it helps.

Flash Gordon
06-15-2005, 09:52 PM
See part 2 for a seperate preloader
http://actionscripts.org/forums/showthread.php3?t=74988

krone
06-16-2005, 01:01 AM
Cheerio alll i needed was this

[as]

_root.onLoad = function() { //this loads the 1.swf as soon as the movie loads
loadMovie("1.swf", _root.holder); // the second parameter: _root.holder sets where 1.swf will be loaded, in this case a movie clip on the main timeline named holder
};

[as]