?
Solved

How do you find your current level?

Posted on 2003-02-22
22
Medium Priority
?
205 Views
Last Modified: 2012-05-04
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
Comment
Question by:tinman8443
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 10
22 Comments
 
LVL 6

Expert Comment

by:henryww
ID: 8002230
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
 

Author Comment

by:tinman8443
ID: 8004515
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
 

Author Comment

by:tinman8443
ID: 8004917
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 6

Expert Comment

by:henryww
ID: 8007546
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
 

Author Comment

by:tinman8443
ID: 8009152
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
 
LVL 6

Expert Comment

by:henryww
ID: 8009724
hey jesse, have u got a link to that swf?
0
 

Author Comment

by:tinman8443
ID: 8009763
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
 

Author Comment

by:tinman8443
ID: 8009779
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
 
LVL 6

Expert Comment

by:henryww
ID: 8009983
sure, i can better understand what u are trying to do and hopefully get it done quickly :)

cheers
0
 
LVL 6

Accepted Solution

by:
henryww earned 900 total points
ID: 8010637
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
 

Author Comment

by:tinman8443
ID: 8010759
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
 
LVL 6

Expert Comment

by:henryww
ID: 8011003
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
 

Author Comment

by:tinman8443
ID: 8012469
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
 
LVL 6

Expert Comment

by:henryww
ID: 8015129
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
 
LVL 5

Expert Comment

by:elhy
ID: 8024106
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
 
LVL 6

Expert Comment

by:henryww
ID: 8024247
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
 

Author Comment

by:tinman8443
ID: 8025347
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
 
LVL 6

Expert Comment

by:henryww
ID: 8025571
leave me a link for the fla and i will have a look for u :)

cheers
0
 

Author Comment

by:tinman8443
ID: 8025611
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
 
LVL 6

Expert Comment

by:henryww
ID: 8025663
... 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
 

Author Comment

by:tinman8443
ID: 8025685
Oh great, thanks a lot! That could have been a mess!
0
 
LVL 6

Expert Comment

by:henryww
ID: 8034052
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question