Problem referencing loaded movies... Driving me NUTS!

ok, I have a mc called: “preloader.swf” that is the first thing people see.

I use this .swf to preload a rather large “main.swf” file into it (the reason I don’t just put the preloader inside “main.swf” on the first few frames is because I got a bunch of linked library items with the “export to first frame” option selected and that makes the library load before the actual file so putting a pre-loader there is pointless).

the “main.swf” consists of 2 frames:

Frame 1:
nothing, just a stop(); on the action layer.

Frame 2:
that’s where everything is. It’s mostly all AS designed website.

The “preloader.swf” is 4 frame long and that’s what I got (I tried sticking as close as possible from the lib tutorial on this site).

Frame 1:
loadMovieNum(“main.swf”, 1);

Frame 2:
bytes_loaded = Math.round(_level1.getBytesLoaded());
bytes_total = Math.round(_level1.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
_root.loadBar_mc._width = getPercent100;
_root.loadText = Math.round(getPercent
100)+"%";
if (bytes_loaded == bytes_total) {
_root.gotoAndStop(4);
_level1.gotoAndStop(2);
}

frame 3:
_root.gotoAndPlay(2);

frame 4:
stop();

If I just put the 1st frame load action, the movie loads fine. And the preloader works fine with a mc from within like in the tutorial. If I do a trace() on getBytesTotal I get 0 (zero). And the gotoAndStop(2) doesn’t work either (even without the “if” statement). So I’m thinking the problem is probably the way I reference the “main.swf” with _level1.etc…
What’s the correct syntax then?

It looks right from everything I read everywhere, but I guess I missed something…

I’m puzzled and getting very frustrated over this one… HELP!!!

try switching the

_root.gotoAndStop(4);
_level1.gotoAndStop(2);

to

_level1.gotoAndStop(2);
_root.gotoAndStop(4);

I tried that already :wink: thx though…

Does that mean the _level1 is right and should work?

I’m going crazy over this…

yeah at a quick glance it looks alright, lemme look at it a little further and if I cant see anything Ill make an example and see if I cant get it to work for me…

thx man!

another thing: iI just tried commenting the
//_root.gotoAndStop(4);
and the “main.swf” loads… But of course “preloader.swf” never get to frame 4…
So the reference to the _level works and the problem is somewhere else…
I’m getting trully confused now…
driving me more and more crazy!!

ok most likely whats going on is that since you are checking the level directly after (well only one frame) you try to load the swf, _level1 is still not defined by the time that code runs. It will be, to flash, undefined. Hense both getBytesTotal and Loaded will also both be undefined and hense immediately equal to each other so you’ll go to frame 4 pretty fast. Also at that time _level1.gotoAndStop is called but since level 1 still isnt defiened at this point, it never gets to frame 2.

I did a post on here either in this forum or the mx forum about loading movies and how this happens with levels.

A quick fix should be something like:

if (_level1){

bytes_loaded = Math.round(_level1.getBytesLoaded());
bytes_total = Math.round(_level1.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
_root.loadBar_mc._width = getPercent100;
_root.loadText = Math.round(getPercent
100)+"%";
if (bytes_loaded == bytes_total) {
_root.gotoAndStop(4);
_level1.gotoAndStop(2);
}

}

Ill test it out just to be sure

cool, i’ll check it out and let you know…
I’m tryin something else first though.

Thx a bunch!!

yeah worked for me

for me to :wink:

YOU DA MAN!! :beam:

I could never have thought about that…
A few days that I’ve been looking in the completely wrong direction (is that english? not my 1st language… sorry!)…
Ho, well…

Back to work!

thx again!!!