1 2 Previous Next 40 Replies Latest reply on Jul 24, 2009 4:29 PM by act5

    ac2 question

    act5

        I have ac on the main timeline frame 1, to duplicate a circle_mc that has the ID linkage on it in the library. The problem is when I put another clip triangle into the code the first 6 are no longer seen when I test movie. What can I do so that all 12 instances are on the stage at the same time.

      My code:

      for(var i = 1; i <= 6; i++) {
      duplicateMovieClip("triangle_mc","triangle_mc"+i, i);
      _root["triangle_mc"+i]._x = 450 * Math.random();
      _root["triangle_mc"+i]._y = 350 * Math.random();
      }
      for(var i = 1; i <= 6; i++) {
      duplicateMovieClip("circle_mc","circle_mc"+i, i);
      _root["circle_mc"+i]._x = 450 * Math.random();
      _root["circle_mc"+i]._y = 350 * Math.random();
      }
        • 1. Re: ac2 question
          kglad Adobe Community Professional & MVP

          you're re-using the same depths.  try:

           


          for(var i = 1; i <= 6; i++) {
          duplicateMovieClip("triangle_mc","triangle_mc"+i, i);
          _root["triangle_mc"+i]._x = 450 * Math.random();
          _root["triangle_mc"+i]._y = 350 * Math.random();
          }
          for(var i = 1; i <= 6; i++) {
          duplicateMovieClip("circle_mc","circle_mc"+i, i+6);
          _root["circle_mc"+i]._x = 450 * Math.random();
          _root["circle_mc"+i]._y = 350 * Math.random();
          }
          • 2. Re: ac2 question
            dalcde Level 1

            K.Glad's option is OK, but you may want another.

             

            for(var i = 1; i <= 6; i++) {
            duplicateMovieClip("triangle_mc","triangle_mc"+i, _root.getNextHighestDepth());
            _root["triangle_mc"+i]._x = 450 * Math.random();
            _root["triangle_mc"+i]._y = 350 * Math.random();
            }
            for(var i = 1; i <= 6; i++) {
            duplicateMovieClip("circle_mc","circle_mc"+i, _root.getNextHighestDepth());
            _root["circle_mc"+i]._x = 450 * Math.random();
            _root["circle_mc"+i]._y = 350 * Math.random();
            }

            If you use _root.getNextHighestDepth(), it would get the highest Depth Available.
            • 3. Re: ac2 question
              act5 Level 1

              Good so far. Not having much luck trying to get my square_mc to

              delete triangle_mc when it roll-over the triangle. Code I'm

              using:_root.onEnterFrame

              = function (){

              for (var i = 1; i <= 6; i++)

              {

              if (square_mc.hitTest (6+))

              {

              delete this.onEnterFrame;

              trace ("Hit");

              }

              if (square_mc.hitTest (triangle_mc))

              {

              delete this.onEnterFrame;

              square_mc.onRollOver = function ()

              {

              trace ("delete");

              };

              }

              }

              };

              Do I also need to have an ID on the square_mc in the library?

              • 4. Re: ac2 question
                act5 Level 1

                >

                >

                >

                • 5. Re: ac2 question
                  kglad Adobe Community Professional & MVP

                  what are you trying to do?  are there 6 square_mc's like the triangle and circle mc's?  and, if square_mc3 is rolled over, remove triangle_mc3?

                  • 6. Re: ac2 question
                    act5 Level 1

                    If square_mc - which is moved on stage using the arrow keys - moves over one

                    of the tringle_mc that the triangle will disapear.

                    • 7. Re: ac2 question
                      kglad Adobe Community Professional & MVP

                      when you move square_mc, use:

                       

                      for(var i = 1; i <= 6; i++) {
                      if(square_mc.hitTest(this["triangle_mc"+i])){
                      this["triangle_mc"+i].removeMovieClip();
                      }
                      • 8. Re: ac2 question
                        act5 Level 1

                        There is three mc's in the library all with ID linkage.  On the stage is one square, six instances of triangles and six instances of circles. Off stage to the side of stage is the original square and triangle,  so that they will not get clicked on when SWF is running. 

                         

                        The script that you gave me to delete an instance of triangle is not allowing the square to delete it

                        • 9. Re: ac2 question
                          act5 Level 1

                          I put a trace on that last code and it is showing up in the output window, but still not deleting.  What is wrong with it?

                          • 10. Re: ac2 question
                            kglad Adobe Community Professional & MVP

                            that code must execute repeatedly whenever square_mc moves.

                            • 11. Re: ac2 question
                              act5 Level 1

                              But its not deleting.  Is there anything else that I need to do with the clips to make it happen?

                              Code in attachment:

                              • 12. Re: ac2 question
                                act5 Level 1

                                Sorry file didn't attach.

                                 

                                Code:
                                stop ();
                                var distance:Number = 10;
                                var keyListener:Object = new Object ();
                                keyListener.onKeyDown = function ()
                                {
                                if (Key.isDown (Key.LEFT))
                                {
                                square_mc._x = Math.max (square_mc._x - distance, 0);
                                //trace ("move left");
                                }
                                else if (Key.isDown (Key.RIGHT))
                                {
                                square_mc._x = Math.min (square_mc._x + distance, 575);
                                //trace ("move right");
                                }
                                else if (Key.isDown (Key.UP))
                                {
                                square_mc._y = Math.max (square_mc._y - distance, 0);
                                //trace ("move up");
                                }
                                else if (Key.isDown (Key.DOWN))
                                {
                                square_mc._y = Math.min (square_mc._y + distance, 570);
                                //trace ("move down");
                                }
                                };
                                Key.addListener (keyListener);
                                // Code for the main timeline
                                // This code duplicates and randomly positions new instances
                                //of the movieClip triangle_mc
                                for (var i = 1; i <= 6; i++)
                                {
                                duplicateMovieClip ("triangle_mc", "triangle_mc" + i, i);
                                _root["triangle_mc" + i]._x = 550 * Math.random ();
                                _root["triangle_mc" + i]._y = 400 * Math.random ();
                                }
                                for (var i = 1; i <= 6; i++)
                                {
                                duplicateMovieClip ("circle_mc", "circle_mc" + i, i + 6);
                                _root["circle_mc" + i]._x = 550 * Math.random ();
                                _root["circle_mc" + i]._y = 400 * Math.random ();
                                }
                                //delete an instance of the triangle with the square
                                for(var i = 1; i <= 6; i++) {
                                if(square_mc.hitTest(this["triangle_mc"+i]))
                                {
                                trace("the square has hit the triangle_mc movieClip");
                                this["triangle_mc"+i].removeMovieClip();
                                }
                                }

                                • 13. Re: ac2 question
                                  act5 Level 1

                                  I am getting a trace in the output window.

                                  • 14. Re: ac2 question
                                    kglad Adobe Community Professional & MVP

                                    again, that code must repeatedly execute whenever square_mc moves:

                                     

                                    act5 wrote:

                                     

                                    Sorry file didn't attach.

                                     

                                     

                                    Code:
                                    stop ();
                                    var distance:Number = 10;
                                    var keyListener:Object = new Object ();
                                    keyListener.onKeyDown = function ()
                                    {
                                    if (Key.isDown (Key.LEFT))
                                    {
                                    square_mc._x = Math.max (square_mc._x - distance, 0);
                                    //trace ("move left");
                                    }
                                    else if (Key.isDown (Key.RIGHT))
                                    {
                                    square_mc._x = Math.min (square_mc._x + distance, 575);
                                    //trace ("move right");
                                    }
                                    else if (Key.isDown (Key.UP))
                                    {
                                    square_mc._y = Math.max (square_mc._y - distance, 0);
                                    //trace ("move up");
                                    }
                                    else if (Key.isDown (Key.DOWN))
                                    {
                                    square_mc._y = Math.min (square_mc._y + distance, 570);
                                    //trace ("move down");
                                    }
                                    //delete an instance of the triangle with the square
                                    for(var i = 1; i <= 6; i++) {
                                    if(square_mc.hitTest(this["triangle_mc"+i]))
                                    {
                                    trace("the square has hit the triangle_mc movieClip");
                                    this["triangle_mc"+i].removeMovieClip();
                                    }
                                    }
                                    };
                                    Key.addListener (keyListener);
                                    // Code for the main timeline
                                    // This code duplicates and randomly positions new instances
                                    //of the movieClip triangle_mc
                                    for (var i = 1; i <= 6; i++)
                                    {
                                    duplicateMovieClip ("triangle_mc", "triangle_mc" + i, i);
                                    _root["triangle_mc" + i]._x = 550 * Math.random ();
                                    _root["triangle_mc" + i]._y = 400 * Math.random ();
                                    }
                                    for (var i = 1; i <= 6; i++)
                                    {
                                    duplicateMovieClip ("circle_mc", "circle_mc" + i, i + 6);
                                    _root["circle_mc" + i]._x = 550 * Math.random ();
                                    _root["circle_mc" + i]._y = 400 * Math.random ();
                                    }

                                    • 15. Re: ac2 question
                                      act5 Level 1

                                      Yes I know it should.  Is there anything else that I can do to the folders and should they all have ID linkage to the library?

                                       

                                      I tried uploading the .fla file but it is taking ages.

                                      • 16. Re: ac2 question
                                        kglad Adobe Community Professional & MVP

                                        did you replace your code with the code i gave?

                                        • 17. Re: ac2 question
                                          act5 Level 1

                                          Yes - still no joy.

                                          • 18. Re: ac2 question
                                            kglad Adobe Community Professional & MVP

                                            try:

                                             


                                             

                                            var tl:MovieClip=this;
                                            stop ();
                                            var distance:Number = 10;
                                            var keyListener:Object = new Object ();
                                            keyListener.onKeyDown = function ()
                                            {
                                            if (Key.isDown (Key.LEFT))
                                            {
                                            square_mc._x = Math.max (square_mc._x - distance, 0);
                                            //trace ("move left");
                                            }
                                            else if (Key.isDown (Key.RIGHT))
                                            {
                                            square_mc._x = Math.min (square_mc._x + distance, 575);
                                            //trace ("move right");
                                            }
                                            else if (Key.isDown (Key.UP))
                                            {
                                            square_mc._y = Math.max (square_mc._y - distance, 0);
                                            //trace ("move up");
                                            }
                                            else if (Key.isDown (Key.DOWN))
                                            {
                                            square_mc._y = Math.min (square_mc._y + distance, 570);
                                            //trace ("move down");
                                            }

                                            //delete an instance of the triangle with the square
                                            for(var i = 1; i <= 6; i++) {
                                            if(square_mc.hitTest(tl["triangle_mc"+i]))
                                            {
                                            trace("the square has hit the triangle_mc movieClip");
                                            tl["triangle_mc"+i].removeMovieClip();
                                            }
                                            }
                                            };
                                            Key.addListener (keyListener);
                                            // Code for the main timeline
                                            // This code duplicates and randomly positions new instances
                                            //of the movieClip triangle_mc
                                            for (var i = 1; i <= 6; i++)
                                            {
                                            duplicateMovieClip ("triangle_mc", "triangle_mc" + i, i);
                                            _root["triangle_mc" + i]._x = 550 * Math.random ();
                                            _root["triangle_mc" + i]._y = 400 * Math.random ();
                                            }
                                            for (var i = 1; i <= 6; i++)
                                            {
                                            duplicateMovieClip ("circle_mc", "circle_mc" + i, i + 6);
                                            _root["circle_mc" + i]._x = 550 * Math.random ();
                                            _root["circle_mc" + i]._y = 400 * Math.random ();
                                            }

                                            • 19. Re: ac2 question
                                              act5 Level 1

                                              Now how do I delete each of the triangles when square rolls over the triangle?

                                              • 20. Re: ac2 question
                                                act5 Level 1

                                                Yes! Yes! Yes!

                                                Is this the only change you made to the code : var tl:MovieClip=this; and what is tl?

                                                 

                                                NOW, if the square touches a circle, the square  should disappears.

                                                • 21. Re: ac2 question
                                                  kglad Adobe Community Professional & MVP

                                                  tl is a reference to the timeline that contains the code where the triangle and circle movieclips were created.

                                                   

                                                  mark the correct answer.

                                                   

                                                  use another looping hittest for the square and circle movieclips.

                                                  • 22. Re: ac2 question
                                                    act5 Level 1

                                                    This is what I have put in below the triangle / square loop, but it is not deleting the square. 

                                                     

                                                    Code:

                                                    //delete the square an instance of with the circle
                                                    for (var i = 1; i <= 6; i++)
                                                    {
                                                    if (square_mc.hitTest (tl["circle_mc" + i]))
                                                    {
                                                    trace ("the circle has hit the square_mc movieClip");
                                                    tl["square_mc"].removeMovieClip ();
                                                    }
                                                    }
                                                    Key.addListener (keyListener);
                                                    Is it because the square is not an instance?
                                                    I have tried many different ways and still not able to delete the square.
                                                    What changes do I have to make?

                                                    • 23. Re: ac2 question
                                                      kglad Adobe Community Professional & MVP

                                                      that code must be inside your listener where the other hittest code is located.

                                                      1 person found this helpful
                                                      • 24. Re: ac2 question
                                                        act5 Level 1

                                                        OooK, it is in the listener - but it is not deleting the square - even though I am getting a trace in the output window.

                                                         

                                                         

                                                        Code:

                                                         

                                                        //delete an instance of the triangle with the square   
                                                        for (var i = 1; i <= 6; i++)
                                                        {
                                                        if (square_mc.hitTest (tl["triangle_mc" + i]))
                                                        {
                                                        trace ("the square has hit the triangle_mc movieClip");
                                                        tl["triangle_mc" + i].removeMovieClip ();
                                                        }
                                                        //delete the square with an instance of with the circle 
                                                        if (square_mc.hitTest (tl["circle_mc" + i]))
                                                        {
                                                        trace ("the circle has hit the square_mc movieClip");
                                                        tl["square_mc"].removeMovieClip ();
                                                        }
                                                        }
                                                        };
                                                        Key.addListener (keyListener);
                                                        What next?

                                                        • 25. Re: ac2 question
                                                          kglad Adobe Community Professional & MVP

                                                          try:

                                                           


                                                           

                                                           

                                                          //delete an instance of the triangle with the square   
                                                          for (var i = 1; i <= 6; i++)
                                                          {
                                                          if (square_mc.hitTest (tl["triangle_mc" + i]))
                                                          {
                                                          trace ("the square has hit the triangle_mc movieClip");
                                                          tl["triangle_mc" + i].removeMovieClip ();
                                                          }
                                                          //delete the square with an instance of with the circle 
                                                          if (square_mc.hitTest (tl["circle_mc" + i]))
                                                          {
                                                          trace ("the circle has hit the square_mc movieClip");
                                                          square_mc.removeMovieClip ();
                                                          break;
                                                          }
                                                          }
                                                          };
                                                          Key.addListener (keyListener);
                                                          What next?
                                                          • 26. Re: ac2 question
                                                            act5 Level 1

                                                            No, still not deleting and I want to add sound yet to the triangle  and circle - when they are touched.

                                                             

                                                            What else can I use?

                                                             

                                                            Changed the script around but no delete.

                                                            • 27. Re: ac2 question
                                                              kglad Adobe Community Professional & MVP

                                                              show your key listener code.

                                                              • 28. Re: ac2 question
                                                                act5 Level 1

                                                                I fear that if this forms gets any longer that I'll be given an award for longest file with Adobe!
                                                                Code:
                                                                //delete an instance of the triangle with the square    
                                                                for (var i = 1; i <= 6; i++)
                                                                {
                                                                if (square_mc.hitTest (tl["triangle_mc" + i]))
                                                                {
                                                                trace ("the square has hit the triangle_mc movieClip");
                                                                tl["triangle_mc" + i].removeMovieClip ();
                                                                }
                                                                //delete the square with an instance of with the circle  
                                                                if (square_mc.hitTest (tl["circle_mc" + i]))
                                                                {
                                                                trace ("the circle has hit the square_mc movieClip");
                                                                square_mc.removeMovieClip ();
                                                                break;
                                                                }
                                                                }
                                                                };
                                                                Key.addListener (keyListener);

                                                                • 29. Re: ac2 question
                                                                  kglad Adobe Community Professional & MVP

                                                                  show all your key listener code from

                                                                   

                                                                  keyListener.onKeyDown = function ()
                                                                  {

                                                                  to the final }
                                                                  • 30. Re: ac2 question
                                                                    act5 Level 1
                                                                    I think you'r actin the monkey with me.
                                                                    I don't have any onKeyPress!!!
                                                                    //delete an instance of the triangle with the square   
                                                                    for (var i = 1; i <= 6; i++)
                                                                    {
                                                                    if (square_mc.hitTest (tl["triangle_mc" + i]))
                                                                    {
                                                                    trace ("the square has hit the triangle_mc movieClip");
                                                                    tl["triangle_mc" + i].removeMovieClip ();
                                                                    }
                                                                    //delete the square with an instance of with the circle 
                                                                    if (square_mc.hitTest (tl["circle_mc" + i]))
                                                                    {
                                                                    trace ("the circle has hit the square_mc movieClip");
                                                                    square_mc.removeMovieClip ();
                                                                    break;
                                                                    }
                                                                    }
                                                                    };
                                                                    Key.addListener (keyListener);
                                                                    for (var i = 1; i <= 6; i++)
                                                                    {
                                                                    duplicateMovieClip ("triangle_mc", "triangle_mc" + i, i);
                                                                    _root["triangle_mc" + i]._x = 550 * Math.random ();
                                                                    _root["triangle_mc" + i]._y = 400 * Math.random ();
                                                                    }
                                                                    for (var i = 1; i <= 6; i++)
                                                                    {
                                                                    duplicateMovieClip ("circle_mc", "circle_mc" + i, i + 6);
                                                                    _root["circle_mc" + i]._x = 550 * Math.random ();
                                                                    _root["circle_mc" + i]._y = 400 * Math.random ();
                                                                    }
                                                                    • 31. Re: ac2 question
                                                                      kglad Adobe Community Professional & MVP

                                                                      then that's a problem.  look at the code that i gave you above that worked to remove the triangle movieclips.

                                                                      • 32. Re: ac2 question
                                                                        act5 Level 1

                                                                        The square should delete the circle on rollOver not on key press.

                                                                         

                                                                        I have tried everything I know but still not able to delete the circle.

                                                                         

                                                                        Only when  I click on script assist - after I have run the movie test - am I getting the following in the output window :

                                                                        **Error** Scene=Scene 1, layer=actionscript, frame=1:Line 37: 'else' encountered without matching 'if'

                                                                             else if (square_mc.hitTest (tl["circle_mc" + i]))
                                                                        Code so far:

                                                                                  //delete an instance of the triangle with the square
                                                                             for (var i = 1; i <= 6; i++)
                                                                             {
                                                                                  
                                                                                  if (square_mc.hitTest (tl["triangle_mc" + i]))
                                                                                  {
                                                                                       trace ("the square has hit the triangle_mc movieClip");
                                                                                       tl["triangle_mc" + i].removeMovieClip ();
                                                                                  }
                                                                                  //delete the square with an instance of the circle
                                                                                  else if (square_mc.hitTest (tl["circle_mc" + i]))
                                                                                  {
                                                                                       trace ("the circle has hit the square_mc movieClip");
                                                                                       tl["square_mc"].removeMovieClip ();
                                                                                  break;
                                                                                  }
                                                                             }
                                                                        };
                                                                        Key.addListener (keyListener);
                                                                        // Code for the main timeline
                                                                        // This code duplicates and randomly positions new instances
                                                                        //of the movieClip triangle_mc
                                                                        for (var i = 1; i <= 6; i++)
                                                                        {
                                                                             duplicateMovieClip ("triangle_mc", "triangle_mc" + i, i);
                                                                             _root["triangle_mc" + i]._x = 550 * Math.random ();
                                                                             _root["triangle_mc" + i]._y = 400 * Math.random ();
                                                                        }
                                                                        for (var i = 1; i <= 6; i++)
                                                                        {
                                                                             duplicateMovieClip ("circle_mc", "circle_mc" + i, i + 6);
                                                                             _root["circle_mc" + i]._x = 550 * Math.random ();
                                                                             _root["circle_mc" + i]._y = 400 * Math.random ();
                                                                        }

                                                                        • 33. Re: ac2 question
                                                                          act5 Level 1

                                                                          But this code that you gave me is not giving errors in the output, but still is not deleting the circles - only the square:

                                                                           

                                                                          //delete an instance of the triangle with the square  
                                                                          for (var i = 1; i <= 6; i++)
                                                                          {
                                                                          if (square_mc.hitTest (tl["triangle_mc" + i]))
                                                                          {
                                                                          trace ("the square has hit the triangle_mc movieClip");
                                                                          tl["triangle_mc" + i].removeMovieClip ();
                                                                          }
                                                                          //delete the square with an instance of with the circle
                                                                          if (square_mc.hitTest (tl["circle_mc" + i]))
                                                                          {
                                                                          trace ("the circle has hit the square_mc movieClip");
                                                                          square_mc.removeMovieClip ();
                                                                          break;
                                                                          }
                                                                          }
                                                                          };
                                                                          Key.addListener (keyListener);
                                                                          Help!

                                                                          • 34. Re: ac2 question
                                                                            kglad Adobe Community Professional & MVP

                                                                            this is the code that includes your key listener:

                                                                             

                                                                            var tl:MovieClip=this;

                                                                            stop ();
                                                                            var distance:Number = 10;
                                                                            var keyListener:Object = new Object ();
                                                                            keyListener.onKeyDown = function ()
                                                                            {
                                                                            if (Key.isDown (Key.LEFT))
                                                                            {
                                                                            square_mc._x = Math.max (square_mc._x - distance, 0);
                                                                            //trace ("move left");
                                                                            }
                                                                            else if (Key.isDown (Key.RIGHT))
                                                                            {
                                                                            square_mc._x = Math.min (square_mc._x + distance, 575);
                                                                            //trace ("move right");
                                                                            }
                                                                            else if (Key.isDown (Key.UP))
                                                                            {
                                                                            square_mc._y = Math.max (square_mc._y - distance, 0);
                                                                            //trace ("move up");
                                                                            }
                                                                            else if (Key.isDown (Key.DOWN))
                                                                            {
                                                                            square_mc._y = Math.min (square_mc._y + distance, 570);
                                                                            //trace ("move down");
                                                                            }

                                                                             

                                                                            //delete an instance of the triangle with the square
                                                                            for(var i = 1; i <= 6; i++) {
                                                                            if(square_mc.hitTest(tl["triangle_mc"+i]))
                                                                            {
                                                                            trace("the square has hit the triangle_mc movieClip");
                                                                            tl["triangle_mc"+i].removeMovieClip();
                                                                            }
                                                                            }
                                                                            };
                                                                            Key.addListener (keyListener);
                                                                            // Code for the main timeline
                                                                            // This code duplicates and randomly positions new instances
                                                                            //of the movieClip triangle_mc
                                                                            for (var i = 1; i <= 6; i++)
                                                                            {
                                                                            duplicateMovieClip ("triangle_mc", "triangle_mc" + i, i);
                                                                            _root["triangle_mc" + i]._x = 550 * Math.random ();
                                                                            _root["triangle_mc" + i]._y = 400 * Math.random ();
                                                                            }
                                                                            for (var i = 1; i <= 6; i++)
                                                                            {
                                                                            duplicateMovieClip ("circle_mc", "circle_mc" + i, i + 6);
                                                                            _root["circle_mc" + i]._x = 550 * Math.random ();
                                                                            _root["circle_mc" + i]._y = 400 * Math.random ();
                                                                            }
                                                                            • 35. Re: ac2 question
                                                                              act5 Level 1

                                                                              That is not including delete the triangle with the square and when I add it in it still does not delete.

                                                                              • 36. Re: ac2 question
                                                                                kglad Adobe Community Professional & MVP

                                                                                 

                                                                                var tl:MovieClip=_root;

                                                                                stop ();
                                                                                var distance:Number = 10;
                                                                                var keyListener:Object = new Object ();
                                                                                keyListener.onKeyDown = function ()
                                                                                {
                                                                                if (Key.isDown (Key.LEFT))
                                                                                {
                                                                                square_mc._x = Math.max (square_mc._x - distance, 0);
                                                                                //trace ("move left");
                                                                                }
                                                                                else if (Key.isDown (Key.RIGHT))
                                                                                {
                                                                                square_mc._x = Math.min (square_mc._x + distance, 575);
                                                                                //trace ("move right");
                                                                                }
                                                                                else if (Key.isDown (Key.UP))
                                                                                {
                                                                                square_mc._y = Math.max (square_mc._y - distance, 0);
                                                                                //trace ("move up");
                                                                                }
                                                                                else if (Key.isDown (Key.DOWN))
                                                                                {
                                                                                square_mc._y = Math.min (square_mc._y + distance, 570);
                                                                                //trace ("move down");
                                                                                }

                                                                                 

                                                                                //delete an instance of the triangle with the square  
                                                                                for (var i = 1; i <= 6; i++)
                                                                                {
                                                                                if (square_mc.hitTest (tl["triangle_mc" + i]))
                                                                                {
                                                                                trace ("the square has hit the triangle_mc movieClip");
                                                                                tl["triangle_mc" + i].removeMovieClip ();
                                                                                }
                                                                                //delete the square with an instance of with the circle
                                                                                if (square_mc.hitTest (tl["circle_mc" + i]))
                                                                                {
                                                                                trace ("the circle has hit the square_mc movieClip");
                                                                                square_mc.removeMovieClip ();
                                                                                break;
                                                                                }
                                                                                }
                                                                                };
                                                                                Key.addListener (keyListener);
                                                                                // Code for the main timeline
                                                                                // This code duplicates and randomly positions new instances
                                                                                //of the movieClip triangle_mc
                                                                                for (var i = 1; i <= 6; i++)
                                                                                {
                                                                                duplicateMovieClip ("triangle_mc", "triangle_mc" + i, i);
                                                                                _root["triangle_mc" + i]._x = 550 * Math.random ();
                                                                                _root["triangle_mc" + i]._y = 400 * Math.random ();
                                                                                }
                                                                                for (var i = 1; i <= 6; i++)
                                                                                {
                                                                                duplicateMovieClip ("circle_mc", "circle_mc" + i, i + 6);
                                                                                _root["circle_mc" + i]._x = 550 * Math.random ();
                                                                                _root["circle_mc" + i]._y = 400 * Math.random ();
                                                                                }
                                                                                • 37. Re: ac2 question
                                                                                  act5 Level 1

                                                                                  No.

                                                                                   

                                                                                  Is this possible at all?

                                                                                  • 38. Re: ac2 question
                                                                                    kglad Adobe Community Professional & MVP

                                                                                    what's the following reveal in the output panel after a brief keydown event:

                                                                                     



                                                                                     

                                                                                    var tl:MovieClip=_root;

                                                                                    stop ();
                                                                                    var distance:Number = 10;
                                                                                    var keyListener:Object = new Object ();
                                                                                    keyListener.onKeyDown = function ()
                                                                                    {
                                                                                    if (Key.isDown (Key.LEFT))
                                                                                    {
                                                                                    square_mc._x = Math.max (square_mc._x - distance, 0);
                                                                                    //trace ("move left");
                                                                                    }
                                                                                    else if (Key.isDown (Key.RIGHT))
                                                                                    {
                                                                                    square_mc._x = Math.min (square_mc._x + distance, 575);
                                                                                    //trace ("move right");
                                                                                    }
                                                                                    else if (Key.isDown (Key.UP))
                                                                                    {
                                                                                    square_mc._y = Math.max (square_mc._y - distance, 0);
                                                                                    //trace ("move up");
                                                                                    }
                                                                                    else if (Key.isDown (Key.DOWN))
                                                                                    {
                                                                                    square_mc._y = Math.min (square_mc._y + distance, 570);
                                                                                    //trace ("move down");
                                                                                    }

                                                                                     

                                                                                    //delete an instance of the triangle with the square  
                                                                                    for (var i = 1; i <= 6; i++)
                                                                                    {
                                                                                    trace(square_mc+" "+tl["circle_mc"+i]);
                                                                                    if (square_mc.hitTest (tl["triangle_mc" + i]))
                                                                                    {
                                                                                    trace ("the square has hit the triangle_mc movieClip");
                                                                                    tl["triangle_mc" + i].removeMovieClip ();
                                                                                    }
                                                                                    //delete the square with an instance of with the circle
                                                                                    if (square_mc.hitTest (tl["circle_mc" + i]))
                                                                                    {
                                                                                    trace ("the circle has hit the square_mc movieClip");
                                                                                    square_mc.removeMovieClip ();
                                                                                    break;
                                                                                    }
                                                                                    }
                                                                                    };
                                                                                    Key.addListener (keyListener);
                                                                                    // Code for the main timeline
                                                                                    // This code duplicates and randomly positions new instances
                                                                                    //of the movieClip triangle_mc
                                                                                    for (var i = 1; i <= 6; i++)
                                                                                    {
                                                                                    duplicateMovieClip ("triangle_mc", "triangle_mc" + i, i);
                                                                                    _root["triangle_mc" + i]._x = 550 * Math.random ();
                                                                                    _root["triangle_mc" + i]._y = 400 * Math.random ();
                                                                                    }
                                                                                    for (var i = 1; i <= 6; i++)
                                                                                    {
                                                                                    duplicateMovieClip ("circle_mc", "circle_mc" + i, i + 6);
                                                                                    _root["circle_mc" + i]._x = 550 * Math.random ();
                                                                                    _root["circle_mc" + i]._y = 400 * Math.random ();
                                                                                    }
                                                                                    • 39. Re: ac2 question
                                                                                      act5 Level 1

                                                                                      I am a lunatic for even trying to open a Flash document!!!!!!!

                                                                                      1 2 Previous Next