1 Reply Latest reply on Dec 29, 2006 3:53 PM by Rothrock

    I want to load an external swf into an mc that is above the current mc....HELP?

      It seems fairly basic.

      I want to load in an external swf into an mc that is above another mc. Once the new swf is loaded in, I want the lower one to be set to _visible = false.

      How would I set this up? Is it a matter of swapping depths?

      Each time a button is clicked, I want the new file to be loaded in on top.

      I was thinking of doing something with levels, so that I load it into the current level + 1. Is that even possible or a good approach. There are infinite levels right?


        • 1. Re: I want to load an external swf into an mc that is above the current mc....HELP?
          Rothrock Level 5
          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.