1 Reply Latest reply on Nov 11, 2009 2:12 PM by shintashi

    Error with actionscript generated MCs

    shintashi Level 1

      if loaded once,buttons work (including the close/delete self function)

      if loaded twice or more before closing/deleting, buttons stop working.

       

       

      I'm running into a problem with "buttons" generated dynamically.

       

      Example Button:

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

      function textscreen(question, answerA, answerB) {

      ... (textfield script) ...

       

      this.createEmptyMovieClip("bclick", getNextHighestDepth());
      bclick.lineStyle (3,0xFFFFFF,0,true,"none","none","miter",10)
      bclick.beginFill (0xFFFFFF,50);
      bclick.moveTo (265, 175);
      bclick.lineTo (315, 175);
      bclick.lineTo (315, 200);
      bclick.lineTo (265, 200);
      bclick.lineTo (265, 175);
      bclick.endFill();

       

      bclick.onPress = function(){kmenu._x = -600; killscreen(); action = 0;}

      }

       

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

       

      I call up these buttons (and their text menu) with scripts like this:

       

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

      function manual(mc, tx) {
      mc.onRelease = function(){
      zquestion = String("Active Command" + "\n" + tx.text);
          actionTrue = tx.text;
                      textscreen(zquestion, "Translate", "Quit");
                          actionBox = actionTrue;
                  }
      }

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

       

      ...which are usually part of some larger menu.

       

      I tried changing this.createEmptyMovieClip("bclick", getNextHighestDepth()); to

      this.createEmptyMovieClip("bclick", 1200);

       

      but asside from preventing the clips from visibly overlapping (I detected the layer density by sitting the initial alpha to 50 to see if the transparency would tend toward opaque with each "load" - which it did until I changed the depth to a static value)

       

      the buttons still stop working after the second load.

       

      Is there a way to put in an "overwrite" or something so my delete command ( killscreen(); ) can "clear" the memory in the event that the load menu function is accidentally called/clicked twice?

        • 1. Re: Fix
          shintashi Level 1

          I added a var called "dialog = 0" to represent "if the dialog box is not on, = 0, if the dialog box is open, = 1; therefore only if the dialog box is not on it works"

           

           

           

          this.createEmptyMovieClip("bclick", getNextHighestDepth());
          bclick.lineStyle (3,0xFFFFFF,0,true,"none","none","miter",10)
          bclick.beginFill (0xFFFFFF,50);
          bclick.moveTo (265, 175);
          bclick.lineTo (315, 175);
          bclick.lineTo (315, 200);
          bclick.lineTo (265, 200);
          bclick.lineTo (265, 175);
          bclick.endFill();

           

          bclick.onPress = function(){dialog = 0; kmenu._x = -600; killscreen(); action = 0;}
          //FF2text._alpha = 90;
          }

           

           

          function manual(mc, tx) {
          mc.onRelease = function(){
                         if(dialog == 0){
              zquestion = String("Active Command" + "\n" + tx.text);
              actionTrue = tx.text;
                          textscreen(zquestion, "Translate", "Quit");
                              actionBox = actionTrue;
                              dialog = 1; //designed to prevent doubleclick
                              }
                     }
          }