• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

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.
0
tinman8443
Asked:
tinman8443
  • 11
  • 10
1 Solution
 
henrywwCommented:
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
0
 
tinman8443Author Commented:
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?
0
 
tinman8443Author Commented:
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!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
henrywwCommented:
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
 
0
 
tinman8443Author Commented:
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
0
 
henrywwCommented:
hey jesse, have u got a link to that swf?
0
 
tinman8443Author Commented:
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
0
 
tinman8443Author Commented:
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.
0
 
henrywwCommented:
sure, i can better understand what u are trying to do and hopefully get it done quickly :)

cheers
0
 
henrywwCommented:
just spot something here

1)
_root.loadlev = ++_root.loadlev;

shoule be

_root.loadlev++; // that will add 1 to the loadlev

2)
and the MC_NAME.getDepth(); <- must have the brackets
and if u don't know the name of the movie u load, u can do with the method as mentioned, create an empty movieclip as a holder for the loaded movie

will wait for ur link
cheers
0
 
tinman8443Author Commented:
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
0
 
henrywwCommented:
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...



0
 
tinman8443Author Commented:
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
0
 
henrywwCommented:
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
0
 
elhyCommented:
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 ;)
0
 
henrywwCommented:
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
0
 
tinman8443Author Commented:
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
0
 
henrywwCommented:
leave me a link for the fla and i will have a look for u :)

cheers
0
 
tinman8443Author Commented:
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?
0
 
henrywwCommented:
... 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
0
 
tinman8443Author Commented:
Oh great, thanks a lot! That could have been a mess!
0
 
henrywwCommented:
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
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 11
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now