2 Replies Latest reply on Sep 15, 2009 7:03 PM by Me2LoveIt2

    interacting Arrays in Flash CS 4


      I have another question.


      continuing from the thread : http://board.flashkit.com/board/showthread.php?t=802542


      If I add another array,
      and put (floor_mc) into the second Array. I want the boxes to fall and then when they hit the floor(floor_mc) stop. Just like in a collision.


      I tried this code:



      //gravity variables
      var gy:Number = 0;
      var gravity:Number = .2 
      var moving:Array = new Array(cube_mc, cube2_mc);
      var ground:Array = new Array(floor_mc)
      this.addEventListener(Event.ENTER_FRAME, gravityFUNC);
      function gravityFUNC(event:Event):void{
           for(var z in moving) { // for each item in the moving array
                moving[z].y+=gy; // apply gravity to each item
      // It workes fine until here
      // I cant get these arrays to interact
      stage.addEventListener(Event.ENTER_FRAME, collide);
      function collide(event:Event):void{

      But it just goes through the floor.



      I believe it is because I still do not completely understand arrays.


      could you help me out? Please


      -Thanks in advance

        • 1. Re: interacting Arrays in Flash CS 4
          Ned Murphy Adobe Community Professional & MVP

          It is a courtesy to those who try to help people to not cross post in different forums.  Thank you for at least indicating that you are cross posting the same questions on different forums.  Knowing that saves folks from wasting their time answering questions that others take the time to provide answers to elsewhere, like the time I wasted today for the first posting you had.


          I'm sure you will get reasonable results if you stick with the one forum at flashkit.com

          • 2. Re: interacting Arrays in Flash CS 4
            Me2LoveIt2 Level 1

            With all do respect, I did not mean to offend you in any way.

            You did not waste your time, I am very grateful for the answer.

            I did not choose to go along with it, since the other code was simpler and still doing what i wanted.

            I am asking the same question in many forums because I believe,

            The more answers I get the more I can learn about coding. As you may have noticed I only started a while ago.

            If you are offended I would do you the courtesy to only post it in one forum first.

            Please help me if you can