0 Replies Latest reply on Jul 24, 2007 11:24 AM by mrthasewer

    Swap Depths with Action Script

    mrthasewer
      Hello:

      I have developed a very simple floor plan creator in flash. See it Here.
      My trouble is. When I go to add windows and walls, after you add a few windows and a few walls the module starts to go awry. The windows always need to stay on top of the walls. (The windows in the movie clip are in a layer that sits on top of a layer of walls so anything on stage works just fine.) When the add windows and add walls buttons are clicked they call items from the library. This is where my trouble starts.

      The first few windows and doors work ok. After adding several, all of the sudden the windows start to be placed below the walls and then the windows and walls start to disappear then reappear when another button is clicked.

      here is the code attached to a vertical window:

      on (press) {
      this.createEmptyMovieClip("v_windowMC"+_global.windowcounter, _global.windowcounter);
      _global.windowcounter +=1;
      duplicateMovieClip(v_windowMC, "v_windowMC"+_global.windowcounter, _global.windowcounter);
      this.v_windowMC._y = -120;
      this.v_windowMC._x = -300;
      _global.windowcounter+=1;
      }

      Here are my global variables
      _global.counter = 1;
      _global.windowcounter = 1;
      _global.wallcounter = 1;
      _global.doorcounter = 1;
      _global.vcounter = 1
      _global.inFrontWindow = 15000;
      _global.inFrontWall = -1000;
      _global.tempWin = 1;
      _global.tempWall = 0;

      and this is the code attached to the walls and doors that sit off stage

      on (release) {
      stopDrag();
      this.swapDepths(_global.tempWall);
      }
      on (press) {
      startDrag(this);
      _global.tempWall = this.getDepth();
      this.swapDepths(_global.inFrontWall);
      }
      (I change the variable based on if it is a wall or a window)

      I was hoping if I made a global variable _global.inFrontWindow = 15000; and a _global.inFrontWall = -1000; that flash would put all my windows on a positive depth and my walls on a negative depth. Keeping my windows on top of my walls.

      Well... This is obviously not the case. So how do I maintain keeping my windows and walls on different depths but keeps my windows in front?

      My coding skills are rather poor and I do not understand all that much about actionScript. So I appreciate any help offered but please keep it simple and assume I know nothing...because that is close to true.

      Thank you very much

      Janalese