5 Replies Latest reply on Dec 24, 2016 7:15 AM by kglad

    How Can I Create Multiple Symbol Children With Code?

    Marsman2500

      I want to create multiple instances of a movieclip (linkage name "my_circle") and control their positions with code. I want to name the instances circle1, circle2, circle3, etc. I tried using EVAL with the code below. It doesn't work.

       

      var itemName = "circle";

      var evalName;

      for (var i = 1; i < 5; ++i) {

           evalName = eval("itemName + i");

           evalName  = new lib.my_circle(); // create instance

           evalName.x = Math.floor(Math.random() * 400); // position instance

      }

       

      this.addEventListener("tick", fl_AnimateHorizontally.bind(this));

      function fl_AnimateHorizontally() {

        circle1.x+=10;

      }