0 Replies Latest reply on Aug 18, 2006 5:23 PM by miquael

    Dynamic MC depth swap

    miquael Level 1
      i have several duplicated movie clips, and want to have 2 buttons that swap the depth of these so that the user can page through (like pages of a book).

      the first part of the code generates the movie clips and puts them on different depths (this all works fine):

      function GeneratePortfolio(portfolio_xml) {
      var portfolioPictures = portfolio_xml.firstChild.childNodes;

      // thumb vars (unrelated)
      var x_pos = 0;
      var y_pos = 0;
      var col_count = 0; // columns
      var col_count_max = 4; // max number of columns per row
      var row_count = 0; // rows
      var row_count_max = 6; // max number of rows per row

      // calculate required number of menu pages
      var menu_max = Math.ceil((portfolioPictures.length) / (col_count_max * row_count_max)) - 1; // number of menu pages required
      trace ("menu_max = " + menu_max);

      // generate menu pages
      if (menu_max > 1) {
      for (var m = 2; m <= menu_max; m++) {
      _root.attachMovie("menu_mc", "menu_mc"+m, this.getNextHighestDepth());
      thisMenu = _root["menu_mc"+m];
      thisMenu.text1 = m;
      thisMenu._x = 14;
      thisMenu._y = 41;

      // move first page to top
      menu_mc1.swapDepths(thisMenu);
      pagation_nav.swapDepths(menu_mc1);
      }
      }
      _root.m_page = 1;
      _root.m_page_swap = m_page;
      }

      -------------------------------------------

      this next part is where i have the problem. this function gets activated when the "next" button is pressed. the traces for both "m_page" and "m_page_swap" register good. but "m_page_swap" comes up undefined when applied to the end of "m_menu", even though this works with "m_page". so, untimately, the swapDepths method does not work.

      can anyone help me?!

      pagation_nav.b_nextPage.onRelease = function() {
      m_page_swap = m_page + 1;

      trace ("m_page = " + m_page);
      trace ("m_page_swap = " + m_page_swap);
      trace ("swap1 " + (_root["menu_mc"+m_page]));
      trace ("swap2 " + (_root["menu_mc"+m_page_swap]));

      _root["menu_mc"+m_page].swapDepths(_root["menu_mc"+m_page_swap]);
      _root.m_page++;
      };


      ~ M