0 Replies Latest reply on Jun 24, 2006 10:26 PM by >Vee<

    wrong counting variable gets used

    >Vee< Level 1
      I have a loop that runs three times. This loop pushes out four movieclip buttons that each use a variable to determine which was pressed, loaded and so on. IN the onLoad portion I have an external jpg get loaded in the first button menu. It works but the progress (in percentage - 100%) gets shown on my third button instead. I know this has to be b/c its the last iteration but im not sure how to fix this. Below is my code:
      var topButtonCount:Number = 3;
      var widthHolder:Number = 0;
      for (var v:Number = 0; v<topButtonCount; v++) {
      var tmp_mc = this.attachMovie("main_menu", top_menu_instance_array[v], this.getNextHighestDepth(), {_y:50});
      tmp_mc._x = widthHolder;
      widthHolder += tmp_mc._width+10;
      //==================================
      tmp_mc.menuName.ivar = v+1;
      tmp_mc.menuName.buttonLabel = top_nav_labels_array[v];
      tmp_mc.menuName.onLoad = function() {
      //disable the first
      btnVar = this.ivar;
      if (_root.btnVar == 1) {
      this.gotoAndStop("disabled");
      this.enabled = false;
      //this gets loaded in the correct spot but triggers the wrong btn. var in the moviecliploader below
      mcl.loadClip("external/img_01.jpg", top_menu_1.loader);
      top_menu_1.loader._x = _x/3;
      top_menu_1.loader._y = 0;
      } else if (btnVar == 2) {
      //mcl.loadClip("blanchee_images/jovani/bb_01.jpg", top_menu_2.loader);
      } else if (btnVar == 3) {
      //mcl.loadClip("blanchee_images/jovani/bb_01.jpg", top_menu_3.loader);
      } else if (btnVar == 4) {
      mcl.loadClip("blanchee_images/jovani/bb_01.jpg", top_menu_4.loader);
      }
      };
      tmp_mc.menuName.onPress = function() {
      btnVar = this.ivar;
      if (_root.btnVar == 1) {
      trace("1r");
      mcl.loadClip(" http://"+masterArray[0 "content_mc");
      tmp_mc[this.ivar].loaderSub.loadMovie("bigRoot_Interactive_s.swf");
      } else if (btnVar == 2) {
      trace("2r");
      mcl.loadClip(" http://"+masterArray[1 "content_mc");
      tmp_mc[this.ivar].loaderSub.loadMovie("bigRoot_InMotion_s.swf");
      } else if (btnVar == 3) {
      trace("3r");
      mcl.loadClip(" http://"+masterArray[2 "content_mc");
      tmp_mc[this.ivar].loaderSub.loadMovie("bigRoot_Image_s.swf");
      } else if (btnVar == 4) {
      trace("4r");
      mcl.loadClip(" http://"+masterArray[3 "content_mc");
      tmp_mc[this.ivar].loaderSub.loadMovie("bigRoot_CaseStudy_s.swf");
      }
      // enable all
      resetTop();
      // resetPopup
      resetPopup();
      // disabled position
      this.gotoAndStop("disabled");
      // disable this button
      this.enabled = false;
      };
      }
      // End of Top Menus [top]
      //=====================================================
      // MovieClipLoader
      //=====================================================
      var mcl:MovieClipLoader = new MovieClipLoader();
      var lo = new Object();
      var loadingMessage:String = "Loading";
      lo.onLoadStart = function(target_mc:MovieClip) {
      title_txt.text = loadingMessage;
      desc_txt.text = loadingMessage;
      if (_root.btnVar == 1) {
      //trace("1s");
      top_menu_1.gotoAndStop("loading");
      } else if (_root.btnVar == 2) {
      //trace("2s");
      top_menu_2.gotoAndStop("loading");
      } else if (_root.btnVar == 3) {
      //trace("3s");
      top_menu_3.gotoAndStop("loading");
      } else {
      trace("h");
      }
      };
      lo.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
      _root["top_menu_"+_root.btnVar].message_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
      if (_root.btnVar == 1) {
      top_menu_1.message_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
      } else if (_root.btnVar == 2) {
      top_menu_2.message_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
      } else if (_root.btnVar == 3) {
      // this is the var that goes off instead of _root.btnVar == 1
      top_menu_3.message_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
      } else {
      trace("l o s t");
      }
      };
      lo.onLoadInit = function(target_mc:MovieClip) {
      trace("finished with the button " + _root.btnVar + " load");
      };
      mcl.addListener(lo);