3 Replies Latest reply on Jun 19, 2006 4:30 PM by Jim_Esteban

    Array driven object constructor

    rbf1787
      Someone please help me, this IS my first post on this forum, but i've done quite a bit of programming with other languages.

      values used:
      var xPos:Number=0;
      var yPos:Number=0;
      var boxMax:Number=20;
      var boxSize:Number=60;

      These are the objectives i'm hoping to complete:

      - create a class with an object constructor whith parameters including x and y coordinates and size.
      - create an array which includes string values of sequential names, ie: "mcBox1","mcBox2","mcBox3"..."mcBox"+x;
      - use the constructor in a for loop, using the array index string as the instance name for the object, each time through the loop it adds the array index++.
      - with each object that is created set the parameters x,y,size, then each time through x+=64, y+=64 (every 5 times using an if else statement).

      in the end i will take this and use the objects to draw movie clips in different areas on the screen and later on use different blending colors and animation, for an intro.

      What i don't know how to do, is how to use a constructor to create a new object using incremental names in a for loop. So that's all i really need to know, i know the rest.

      If you know of a more efficient way of doing this task the PLEASE let me know, that'd be great.

      thanks.