3 Replies Latest reply on Mar 11, 2010 4:42 PM by kglad

    Pop/Push MC to stage help


      I'm new to Actionscript 2.0 and I need some feedback on my (first!) attempt to create an array that will contain 8 instances of 2 different movieclips. As each (checkmark MCs) is added to the stage, another attention getter clip will be removed (circle MCs). So on my first frame of this command one bluecircle should be popped from the stage, and one bluecheck pushed. Then the same with the green clip on the next frame, again back to the blue's on the following frame, and finally both one blue set and one green set.



      invis_Btn.onRelease = function() {
          this.enabled = false;
          rt_Btn.enabled=true, new Tween(rt_Btn, "_alpha", 20, 100, 6, false);


      invis_Btn.addEventListener("click", markerPush)


      Poor attempt at an array


      var markerArr:Array = new Array("bluecircle", "bluecheck"+i, "greencircle", "greencheck"+i, "bluecircle", "bluecheck"+i, "greencircle", "greencheck"+i);
      for (i=0; i<8; i++) {
          var bluecheck:MovieClip = attachMovie("bluecheck"+i, this.getNextHighestDepth(), {_x:260, _y:400});
          var bluecircle:MovieClip = attachMovie("bluecircle"+i, this.getNextHighestDepth(), {_x:260, _y:400});
          var greencheck:MovieClip = attachMovie("greencheck"+i, bluecheck.getNextHighestDepth(), {_x:260, _y:400});
          var greencircle:MovieClip = attachMovie("greencircle"+i, bluecircle.getNextHighestDepth(), {_x:260, _y:400});
          function markerPush(event):Object {
              return markerArr.pop(bluecircle);
              return markerArr.push(bluecheck+i);



      I had attached them and removed them via strict declarations of attachMovie(...) and removeMovieClip(...) linked to the next/previous buttons I had encoded but found that this was a bit buggy as it sometimes generated extra clips that weren't necessarily added and removed correctly depending on the step the user was at. Any suggestions? Am I approaching this with an improper solution? Would a switch command work better?


      Thanks in advance for any help!!

        • 1. Re: Pop/Push MC to stage help
          kglad Adobe Community Professional & MVP

          the first error i see is the use of actionscript 3 on line 7 when the rest of your code is as2.


          the next error i see is the line defining markerArr when i is undefined.


          and, further into your code, you have a function markerPush() being repeatedly defined for no apparent reason.


          i think you would do better to delete all the code and start over.  you should consider planning this project to be displayed in one frame.

          1 person found this helpful
          • 2. Re: Pop/Push MC to stage help
            theideafarmer Level 1

            Gotcha on the undefined i. My thinking was a for loop would give the range I was pushing into the array, which is 8 items. Is the event listener the AS3 code you're mentioning? I thought that listeners like this were defined in AS2...


            Deleting all the code and starting over isn't an option. This program is fully functional aside from this array. I'm not going to trash an entire project for a single bit of code that I've no experience with, and am having problems getting functional because it doesn't address the issue.


            I'm not following your assertion of markerPush() being repeatedly defined as I'm trying to have the invis_Btn trigger the listener (apparently the AS3 code I need to fix?) which in turn triggers the array to add the items to the stage.

            • 3. Re: Pop/Push MC to stage help
              kglad Adobe Community Professional & MVP

              your one function is within a for-loop.  why?


              and what do you want your array to contain and what will you use the array for?