This content has been marked as final. Show 1 reply
Well infinite is a really big number. There are more levels than you will ever need, but probably not infinite!
If you are going to be loading up and up and up. And just setting the previous content to _visible=false, you are most likely going to run into some memory problems sooner or later. If you aren't going to use the content again it would be better to unload() it.
This is a fairly basic thing and can become as complicated as you wish to twist it.
First, if you are going to just keep incrementing the _level why would it involve swapDepths()? No swapping would be needed. (Oddly enough, you can use swapDepths() with a level, but to my mind it is a crazy confusing idea.) swapDepths() is for swapping the depths of two movieclips or of setting one clip at a specific depth. And this is probably what I would use.
Personally I wouldn't use _levels. I think they are awful and not really in-line with the central (to my mind anyways) metaphor of Flash: The MovieClip class. I mean compare the entries for the MovieClip and _level classes. Whoops, there isn't even a _level class!
Depending exactly upon what you are doing, here is what I would do.
Have two clips, perhaps Content0 and Content1. (With one on top.)
I would define a variable such as onTop=1;
I would then use the MovieClipLoader class to load content into Content0.
Using the onLoadInit event handler I would set the _visibility of Content1 to false and unloadClip() its content if any.
Still in the onLoadInit I would swap the clips.
Change the onTop variable to 1.
The next clip would load into 0 and so forth.
If you don't know how to use the MovieClipLoader class, I suggest you first do that. It is sometimes difficult to learn multiple things at once. Figure out how to use the MCL and its events first. Then worry about the part of swapping and all.