2 Replies Latest reply on Aug 30, 2006 6:53 PM by new2oop

    creating an array of movieclips in AS2 oop

    new2oop Level 1
      Long time proceedural programmer trying to switch to OOP. Using the book "Object Oriented Actionscript for Flash 8" I've created the example of a class with a movieclip passed to it as a parameter. Trying to expand that to an array of clips/classes and without success.

      Here's the class:

      class Location extends MovieClip {

      var targetMC:MovieClip;
      var x:Number;
      var y:Number;

      function Location(targetMC:MovieClip, x:Number, y:Number) {
      this.targetMC = targetMC;
      this.x = x;
      this.y = y;

      function moveTo(x:Number,y:Number) {
      this.targetMC._x = x;
      this.targetMC._y = y;

      and for a single clip the following works well in the fla

      var myLocation:Location = new Location(dot, 200,300);

      However when I try to create an array of 'dots' it doesn't work.

      var myLocation:Array = new Array();
      for(x=0;x<5;x++) {
      var myLocation[x]:Location = new Location(_root["dot"+x], 200,100+x*30);

      Also how do I avoid using the _root command in this?