3 Replies Latest reply on Aug 19, 2007 2:47 PM by kglad

    attach movie with for loop in AS3?

      Hi, having trouble figuring out how to do this in AS3 since 'myClip.name' property doesnt seem to change the actual variable....

      The old way I could attach a series of movies from the library with dynamic instance names that I could then target and modify:

      for (n=0; n<5; n++) {
      container.attachMovie("libraryClip", "myNewMovie"+n, n, {_x:(n*10), _x:(100)};
      myNewMovie4._xscale = 200
      myNewMovie4._yscale = 200

      What do I need to add to tweak new way to get it to work with a dynamic var name?

      for (n=0; n<5; n++) {
      var myNewMovie:MovieClip = new libraryClip();
      container.myNewMovie.x = n*10;
      container.myNewMovie.x = n;

      I tried adding as the last line of the for loop: container.myMovie.name = "myNewMovie"+n ; but apprently .name is just a property now and won't actually let me target it by the new name.

      I can get all the lines to accept a dynamic variable except the left side of the var myNewMovie:MovieClip = new libraryClip(); which wont work with any formatting I can think to try :(

      for (n=0; n<5; n++) {
      var ????????? = new libraryClip();
      container.root["myNewMovie"+n].x = n*10;
      container.root["myNewMovie"+n].x = n;

      If anyone can help would be greatly appreciated!