1 Reply Latest reply on Jul 21, 2009 11:26 PM by Ned Murphy

    for loop code migration

    DJ Foosh

      I found this code in an AS2 .fla and would like to use it in AS3.  (The idea is to throw a random number of copies of the movieclip "star_mc" on the stage via AS). 



      for (var i =0;i<50;i++) {





      I get this error message:  TypeError: Error #1006: duplicateMovieClip is not a function.

      at many_fla::MainTimeline/frame1()

        • 1. Re: for loop code migration
          Ned Murphy Adobe Community Professional & MVP

          The duplicateMovieClip method was removed in AS3 and does not have an equivalent directly replacing it.  In order to do what you want you will have to assign a class identifier to the object in the library (via the Linkage option) and use that to create new instances...


          for (var i:int=0;i<50;i++) {

               var star:Star = new Star();

               star.name = "star"+String(i);

               star.x = Math.random()*350;