Link to home
Start Free TrialLog in
Avatar of tinman8443
tinman8443

asked on

How do you find your current level?

How can I use the actionscript to call up the current level?

I am trying to load a flash movie onto a level higher than the one it is currently on then after the animation is finished unload the layer below it. I can't seem to get variables to pass from one level to the next. The levels will increase everytime a new movie is loaded but I can't figure out how to get the currently loaded movie to know which level it's on and load a new movie onto a higher layer. The reason I need this is that I am building a navigation that when a button is pressed a new flash movie loads and covers the one below it, but it is important that the lower layer remain visible (or at least the uncovered parts) until the animation is finished.
Avatar of henryww
henryww

hi tinman8443,

if u have MX u can use MovieClip.getDepth
to determine the depth of a movie clip

otherwise, if u can have a variable to keep track of the movieclip's level when it is loaded.

//eg.
lvlStack = 1;


_root.loadMovie("myMovie.swf","mc"+lvlStack,lvlStack);
myMC = eval("_root.mc" + /:lvlStack);
myMC.myLevel = /:lvlStack;
/:lvlStack ++;
..
..
..

_root.loadMovie("anotherMovie.swf","mc"+lvlStack,lvlStack);
myMC = eval("_root.mc" + /:lvlStack);
myMC.myLevel = /:lvlStack;
/:lvlStack ++;


// this way the lvlStack keeps track of the level
// name the movieclip that loads with the level as well so it can be detemined by the name alone (u can do without the mc, just name it with the level - so a number)
// assign the variable myLevel = lvlStack ...
// etc etc

hope this helps

cheers
Avatar of tinman8443

ASKER

OK I was trying to use Flash5 but I decided to try it in MX. The problem I am having now is that I can't get the getdepth command to work. I don't know how to name a movie loded into a new level, so what do I put before the getDepth command? MoviClip.getDepth is undefined, I am new to using levels and this is confusing me, how do I get it to return the actual level that movie is playing on?
I can't seem to get variables to see outside the scope of the loaded movie.

I have tried setting variables to _root.levnum I have tried _global.levnum and _level0.levnum, when ever I call on these variables from higher levels they ALWAYS come up undefined.

I am about to just make the whole site in HTML!!!! UGH! help please!
see if u can post the actual code... it will definitely help to pin point the porblem.

if u have mx, the problem can be easily solved.

eg.

//frame 1
var lvlStack = 0;

//frame 2
lvlStack++;
_root.createEmptyMovieClips("mc"+/:lvlStack,/:lvlStack);
_root.loadMovie("external1.swf","mc" + lvlStack);

lvlStack++;
_root.createEmptyMovieClips("mc"+/:lvlStack,/:lvlStack);
_root.loadMovie("external1.swf","mc" + lvlStack);

// or a for loop .. etc


//frame 3
trace(_root.mc1.getDepth()); // will give u 1
trace(_root.mc2.getDepth()); // will give u 2 in the debug window

... etc

cheers
 
Frame2 root movie --
stop ();
ifFrameLoaded (2) {
    loadlev = 1;
    loadMovieNum ("main.swf", loadlev, "POST");
}

Main.swf Last frame of the intro animation --
stop ();
if (_root.loadlev != 1) {
    unloadlev = _root.loadlev - 1;
    unloadMovieNum (unloadlev);
}

When button is clicked to go to next section --
on (release) {
    _root.loadlev = ++_root.loadlev;
    loadMovieNum ("academics.swf", _root.loadlev);
}

THen it should unload the last movie once the top one is done covering the lower level. I can use Flash MX also, but I couldn't get the MovieClip.getDepth to return a value, it just kept saying undefined. I can't figure out how to get it to return anything.

Thanks for your help, I'll even up the points if we can solve this.

-Jesse
hey jesse, have u got a link to that swf?
Frame2 root movie --
stop ();
ifFrameLoaded (2) {
    loadlev = 1;
    loadMovieNum ("main.swf", loadlev, "POST");
}

Main.swf Last frame of the intro animation --
stop ();
if (_root.loadlev != 1) {
    unloadlev = _root.loadlev - 1;
    unloadMovieNum (unloadlev);
}

When button is clicked to go to next section --
on (release) {
    _root.loadlev = ++_root.loadlev;
    loadMovieNum ("academics.swf", _root.loadlev);
}

THen it should unload the last movie once the top one is done covering the lower level. I can use Flash MX also, but I couldn't get the MovieClip.getDepth to return a value, it just kept saying undefined. I can't figure out how to get it to return anything.

Thanks for your help, I'll even up the points if we can solve this.

-Jesse
sorry I accidently reposted the last message, ummm... It's not up yet but I can get it up soon. I will post again in a while.
sure, i can better understand what u are trying to do and hopefully get it done quickly :)

cheers
ASKER CERTIFIED SOLUTION
Avatar of henryww
henryww

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK, I decided to abandon the whole concept of how that loads

I posted this so you could see it.

www.thegat.com/test

the only working link at the moment is the one for academics and then the one for thegat once you are on the academics page and since the hit it too big on thegat you have to click on the left side of academics, you will see the idea I decided to settle for, what I really wanted to happen was have the arrows cover the layer below it but instead I had the animation undo itse;f then load the next section. Let me know what you think. When I see your reply to this message I will award you the points, thank you for your help even if I couldn't really get it.

thanks,
Jesse
cool site :) honestly
i like the style

well, i really want to help and see what is that problem with the getDepth or the _root.loadlev ...

it looks really cool with the arrows, but i still don't understand exactly what u are trying to do.

from the academic -> thegat -> green arrows opens -> reveal the gathering -> blues arrow close -> back to thegat... looks pretty good...

where is the load/unload problem? i am sorry, i really can't spot it ... a bit slow on that one...



Thanks for the compliment.

The thing I wanted to do was instead of having the arrows leave and go to black, then have new arrows come in for the next sections, i wanted to be able to to just have the arrows for the next section cover the previous section, so there would be no outro, then when the new animation had fully loaded the level below it would unload (for memory reasons obviously) but I guess this is just as good, I just had my heart set on the other way. If you are really interested I could program a little verision of it that hard codes the level numbers in, it just won't let you go to section that load on lower level because the upper levels cover it. I know it may soundconfusing. I really appreciate you sticking with me on this problem, I am going to increase the points because you have tried so hard to help.

Thanks,
Jesse
hey it is always fun to help, the harder & more mysterious the problem is, the more satisfaction we get in return.

let me say that again .. so u want the arrows, close in on top of the existing section while the next section is loading. when the loading is completed, "level below it would unload" - that's the arrows? or the previous section?

now it depends on how much u want it the original or this "other way". if u really want to find out how to deal with the load/unload, i am as much interested as u want it.

so, send me the fla (link) if you want to get it done. i am 100% it can't be done, it could be just a little comma somewhere that's missing ... :)

cheers
hi tinman8443,

I guess its the pointing of the variable, that's why u are getting undefined.

1. where is ur loadlev variable? Is it in _level0, _level1 etc?

2. actually there's no need to keep changing the level each time u load a new movie. You can simply load it back to _level1. If you have a movie (A) in _level1 and u load a new movie (B) to _level1, the old movie (A) will unload itself and load the new movie (B). This will also make things easier as u have to watch for _level0 and _level1 only.


If there's something I missed out, let me know ;)
elhy u are right if we are doing a "curtain effect", close the curtain on top and load every to the same level under it and replace the old one

but tinman8443 is a doing something like "stack on top" so it is necessay to unload the previous loaded (lower level - save memory) and keep track of the highest level.

cheers
Hey people on dialuip are telling me that it hangs in the middle of the animation as if it is still loading after it starts. Could there be something wrong with my preloader too?

here is a link to the psuedo finished site, I still have to fill in most of the content and correct typos, and add sounds (which is gonna be a huge pain). And I am going out of town for a week where there are no computers, but I'll send you the fla once I get access to it.

www.thegat.com

-Jesse
leave me a link for the fla and i will have a look for u :)

cheers
Do you have to have the preloader in the same scene?
I think I put it in it's own scene.... Would that stop it from preloading the next scene?
... scenes are discontinued timelines

say if u have the preloader in scene1
and then in scene 2, u call the scene1's preloader it won't work.

timeline & elements are not shared between scenes
Oh great, thanks a lot! That could have been a mess!
so tinman,

have u solved the problem??
i still think that loading & unloading can be done easily, maybe is something related to the scenes thing that u were talking about ...

let me know if u need more help on this


cheers