1 Reply Latest reply on Sep 15, 2009 1:08 PM by Ned Murphy

    Putting objects(Instance Names) Into an Array in Flash CS4

    Me2LoveIt2 Level 1

      I worked again on a new Project and stumbled while trying Arrays.


      I have two cubes(cube_mc, cube2_mc) in my scene.


      My code:


      var gy:Number = 0;
      var gravity:Number = .2 
      var moving:Array = new Array(cube_mc, cube2_mc);
      this.addEventListener(Event.ENTER_FRAME, gravityFUNC);
      function gravityFUNC(event:Event):void{


      I was trying to put both cubes into the array,


      and then affecting the whole Array with gravity.


      When I test it nothing happens, and it shows no errors.


      Does anyone know what I am doing wrong?


      -Thanks in advance

        • 1. Re: Putting objects(Instance Names) Into an Array in Flash CS4
          Ned Murphy Adobe Community Professional & MVP

          You are not addressing the elements of the array, and I'm a little surprised that an array is allowed to be assigned a y value without any error.  Try changing the function to loop thru the array as follows:



          function gravityFUNC(event:Event):void{
               for(var i:uint = 0; i<moving.length; i++){



          1 person found this helpful