Groups | Blog | Home
all groups > flash actionscript > september 2005 >

flash actionscript : LoadMovieNum generic layer?



cre8ive1974
9/9/2005 8:58:01 PM
Does LoadMovieNum have a way to tell the movie to load in the next available
level with out specifying that number of the level?

or is there away to swap levels for a movie.swf that has already been added to
a level?

i.e. a movie is loaded into level 10, I hit a button and that movie is moved
to level 9.

any ideas?

Thanks!
D
Alex Fex
9/9/2005 10:03:45 PM
NSurveyor
9/9/2005 10:20:28 PM
Depths and levels are too similar but EXTREMELY different things! Every
timeline and level has depths in it. You can load content into these levels
which will order them in their timeline - ONLY in there timline. No matter
what, _level3 content will be above _level2 content. Think of it this way...
each level is a really big box. These level boxes are stacked ontop of each
other, where _level0 is at the bottom, and _level1 is above it, and _level2
above that box, etc. Inside each level box there are millions of boxes stacked
on top of eachother. These million boxes are the depths for the big level it is
in. If you put an item in the highest box in the level 2 box, it is impossible
for it to be higher than an item in a level box above it. Hopefully that makes
sense...

Put this on frame 1:

_global.loadMovieNumHighest= function(url){
var n = 0;
while(_root["_level"+n]){n++;}
loadMovieNum(url,n);
return n;
}

Then, instead of something like:
loadMovieNum("dsofi.swf",10);

use:
levelNum = loadMovieNumHighest("dsofi.swf");
trace(levelNum);





Roks-1
9/9/2005 10:31:24 PM
Alex is right ,
Use this code:

loadMovie("myMovie.swf", this.getNextHighestDepth());

that should do it.

Rothrock
9/9/2005 11:15:34 PM
Hey NSurveyor, actually if you do this _level2.swapDepths(_level3); I don't
think level 3 content will be above level 2. (You probably already knew this
and were just trying to make it clear without distraction. :)

BTW, nice idea with the code there are two potential problems I see with it.
If there is a large file loading into a given level the test _root["_level"+n]
will return false until at least the first frame (or the entire content) is
loaded. It isn't like with movie clips where you can create an empty clip. In
this case I think it would start loading into a level that was already spoken
for.

And of course if you are disciplined and use the new loadMovieNumHighest() it
is possible you would get gaps. Of course that isn't really a problem with you
code.

cre8ive1974 ? For this reason and others I just think levels are of limited us
in Flash. IMEHO they just don't go with what I view as the prominent paradigm
of Flash, namely the MovieClip. It seems like what you want will tricky (if
even possible with _levels.) And while you can use swapDepths with levels it is
just so much easier and sensible with movieclips.
NSurveyor
9/10/2005 12:00:00 AM
Yup... I knew it ;) If you were paying attention, everything is in boxes. So,
if you use swapDepths, you can obviously switch the big boxes around, and then
the little boxes in the original lower big box will be higher than the little
boxes in the original big box... And also getNextHighestDepth does work as
well... I knew that of course as well ;)
cre8ive1974
9/12/2005 12:00:00 AM
Thanks for all your help everyone!

cre8ive1974
9/12/2005 12:00:00 AM
Okay I tried the post from Alex and Rich but it did not work. I am still
pretty new at all this and the code form Nsurveyor is still a little beyond my
understanding...(I don't want to reference code I don't understand yet as I
want to get a handle on this AS stuff)

I have a movie clip on the main timeline. On that same time line, I also have
a button. I attached the
loadMovie("myMovie.swf",this.getNextHighestDepth()); code to the button. when
I test the movie it does not give me an error, but it also does not do anything
as well....do i need something else? Am I doing anything wrong?

Thanks!
D
NSurveyor
9/12/2005 8:00:07 PM
Sounds to me like you just want to show one SWF at a time on top of the current
timeline? Why not just load everything into one depth? For example, sometime in
your code use:
loadMovieNum("dsofi.swf",10);

and then later you can use:
loadMovieNum("sdfo8.swf",10);

and load sdfo8.swf into level 10, replacing the old movie. BTW, if you want to
unload a movie num, use:

unloadMovieNum(levelnumber);
ssfanetti
9/12/2005 8:13:28 PM
Is it absolutely necessary to load your swfs with loadMovieNum? This old
command is not as useful as it once was and it has some major drawbacks when
you need to load and unload movies on the fly.

Have you tried creating a empty target clip that you can use to load your swfs
into? using a target clip allows you to use the MovieClipLoader object and
makes accessing/controlling your swfs much easier.

example:

target_mc = createEmptyMovieClip('target_mc',_root.getNextHighestDepth());

my_mcl = new MovieClipLoader();
my_listener = {};

my_mcl.addListener(my_listener)

my_mcl.loadClip("foo.swf",target_mc);

to load into a higher clip while preserving the current "foo.swf" container -
just create another container.

target2_mc = createEmptyMovieClip('target2_mc',_root.getNextHighestDepth());

my_mcl.loadClip("bar.swf",target_mc);

to unload them simple use the removeMovieClip command

target_mc.removeMovieClip();
target2_mc.removeMovieClip();



cre8ive1974
9/13/2005 12:00:00 AM
What I'm trying to do is fade in a movie clip over an existing movie clip, kind
of a tansitional effect. If I load the movie over the exisitng movie, as in
loadMovieNum the movie i am loading over will be unloaded and the effect does
not work.

Originally I was using LoadMovieNum and just adding the movies to individual
layers one on top of each other. That worked great if I went from level 1 to
level 2, but if I wanted to go from level 2 back to 1 you could not see the
effect as 2 is loaded into 2 and 1 is loaded into 1 right below 2...

AddThis Social Bookmark Button