0 Replies Latest reply on May 17, 2007 6:47 AM by absurd29

    passing movieClip names to different buttons/MCs

    absurd29
      I have 5 MCs on stage, acting as buttons (ChoiceA_mc to ChoiceE_mc) - referred to in a loop (instead of individually naming them). I have to disable all these MCs when one has been pressed & reactivate them when the 'Next Question' button is pressed. My script works but I think there is a much more efficient way of doing it - so I don't have to repeat the 'for' loop 3 times.
      I'd be grateful if anyone can show me a more efficient way of doing this. Script is :

      next_btn._alpha = 20;
      next_btn.enabled = false;
      ///////////////////////////////////////
      // define content and actions for each answer button:
      var choice:String;
      for (var i = 65; i<=69; i++) {
      choice = "choice"+String.fromCharCode(i)+"_mc";
      this[choice].letter_txt.text = String.fromCharCode(i);
      this[choice].id = String.fromCharCode(i);
      // when this answer is chosen:
      _root[choice].onRelease = function() {
      for (i=65; i<=69; i++) {
      var allButts:MovieClip = this._parent["choice"+String.fromCharCode(i)+"_mc"];
      allButts.enabled = false;
      allButts.gotoAndStop("_up");
      }
      next_btn._alpha = 100;
      next_btn.enabled = true;
      };
      }
      next_btn.onRelease = function() {
      this._alpha = 20;
      this.enabled = false;
      //show all 5 answer btns again:
      for (i=65; i<=69; i++) {
      allButts = this._parent["choice"+String.fromCharCode(i)+"_mc"];
      allButts.enabled = true;
      }
      };