3 Replies Latest reply on Aug 11, 2008 11:46 AM by Rothrock

    Flash Depth Problem!

    Pettor_swe
      Hi!

      I'am creating a bar with images scrolling inside. So my project right now have 3 layers. 1 layer with actions at the bottom, 1 layer above with a border and finally 1 layer above with at fading effect. The problem is that the images created with actionscript in layer 1, while the other two layers contain a movie clip (or graphic object) each, is displayed above everything else. I have tried swapDepths(), maybe i can't understand how to use it?

      The layer 1 code:

      for (i=1; i<=4; i++)
      {
      _root.createEmptyMovieClip("imageHolder"+i,i);
      setProperty("imageHolder"+i, _y, picty);
      loadMovie("BildTest"+i+".jpg", "imageHolder"+i);
      picty = picty+164;//Increase the y-counter with 164 pixels (this is the height of a picture)

      }

      I have tried to make a movie clip of the border in layer 2 with the code:

      onClipEvent (load)
      {
      this.swapDepths(2000000000000);

      }

      So how to get rid of this very irritating problem?

      Thanks for any help!
        • 1. Re: Flash Depth Problem!
          Rothrock Level 5
          I want to help you, but there are so many issues here. First and foremost is that you are using an old style of code that you really should dump. The next is that I'm really confused by exactly what the problem is. So let's do this a bit at a time.

          First layers mean nothing in the published swf file. They are just a method to allow the author to organize there work. At publish time they are used to determine the stacking order of the artwork and then they are discarded. So talking about layers only confuses the issue. Instead talk about symbol instances -- movieclips, graphics, buttons, etc.

          The next issue is the setProperty issues. While not directly related to your problem I just can't let this go by. It is outmoded and depreciated and goes away in newer versions of Flash. So instead of using setProperty just set the property!

          The trick here is that the createEmptyMovieClip method returns a reference to the clip you just created so you can use that to reference the clip. Like this:

          var curHolder:MovieClip=this.createEmptyMovieClip("imageHolder"+i,i)
          curHolder._y=pictY;
          loadMovie("bildTest"+i+".jpg",curHolder);
          and so on....

          Next thing is that most likely you should use loadMovie. There is a time delay between when you request an external file and when it actually gets loaded. There are also many things you can't do until the clip is loaded. In the olden days (when loadMovie was all we had) you often needed to make a "preloader" to check when the movie was loaded and it could get a little comples. Nowadays (if you are publishing for Flash 7 or later) it would be better to use the MovieClipLoader class. If you have interest in doing that, post back and we can get that sorted.

          Okay finally now onto the depths issue in general. Here is a tutorial that explains everything about depths in Flash:

          http://www.kirupa.com/developer/actionscript/depths.htm

          The basic problem I think you are running into is sort of like the floors of a tall building. You have the main timeline which is like the building. Each of its children clips are like a floor in the building and each of their children clips are like bookshelf on a given floor. So for example you've got something on the lowest level of the bookshelf on floor one. You can move it to the top of the bookshelf on floor 1, but no matter how high you move it, the highest thing on floor 1 will always be below the lowest thing on floor 2.

          Now we depart from reality a bit, but imagine you can move the entire floor of a building! So now floor one is swaped with floor 2. But everything on floor 1 has to go with floor one so all of its "children" go with it. There is no way to have half the stuff on Floor 1 stay below floor 2 and the other half above.

          This little idea -- that the depths count restarts each time you have a new clip trips up a lot of folks. I'm not following the exact structure of your layout, but I'm guessing that is what is causing the problem.

          Also as the link above will show you, the number you are using in the swapDepths is a bit too big. There are a lot of depths, but not that many.
          • 2. Re: Flash Depth Problem!
            Pettor_swe Level 1
            Sorry for the late reply!

            However thanks for the info! It worked fine now and i think i understand how depths work.

            However you write:

            "Next thing is that most likely you should use loadMovie. There is a time delay between when you request an external file and when it actually gets loaded. There are also many things you can't do until the clip is loaded. In the olden days (when loadMovie was all we had) you often needed to make a "preloader" to check when the movie was loaded and it could get a little comples."

            Here i guess you don't refer to loadMovie in the first sentence but just wrote wrong? Because loadMovie has this delay and i think i need to get rid of it. Right now i need some kind of preloader.
            • 3. Re: Flash Depth Problem!
              Rothrock Level 5
              I was on vacation so I didn't see this 'til just now. And yes, I meant to say that you shouldn't use loadMovie.

              Have you worked out how to use the MovieClipLoader class? Do you need more help?