3 Replies Latest reply on Oct 4, 2012 8:35 AM by odgar

    Renaming multiple instances on stage

    odgar

      Hi there,

       

      I was wondering whether there was a way to rename instances that are physically on the stage other than the laborious clicking on the symbol and then changing it in the properties panel.

       

      For example, I have thirty buttons in one frame with the names: s1b1, s1b2, s1b3, s1b4 etc to s1b30.

       

      I've copied and pasted these to a separate frame, where I now want their instance names to be s2b1, s2b2, s2b3, s2b4 ...

       

      Ideally what I'm looking for is a way to highlight all the buttons I need to change the name of, and then do a find and replace on the instance name for 's1' to 's2'.

       

      Is there any way to automate this process or am I in for the long haul? :-(

       

      Thanks in advance

       

      Alex

        • 1. Re: Renaming multiple instances on stage
          odgar Level 1

          Found the answer, so will post it here in case it's any use to anyone else.

           

          Someone (MichaelxxOA) very helpfully wrote a Flash command script that does this.

           

          http://www.actionscript.org/forums/showthread.php3?t=111969

           

          var removeString = "s1"; // Find

          var replaceString = "s2"; // Replace

          var items = fl.getDocumentDOM().selection;

          for (var i=0; i<items.length; i++) {    var pos = items[i].name.indexOf( removeString  );

          if ( pos != -1 )    {       items[i].name = items[i].name.split( removeString ).join( replaceString );

          }

          } //

           

           

          In a text editor, save this as a .jsfl file called InstanceRenamer (or something) in your Flash / Common/ First Run / Commands folder.

           

          Then select the buttons you wish to find replace on in Flash and run this command from the Commands panel in Flash.

           

          Just change the first two lines in a text editor everytime you want to change the find/replace terms and run again.

           

           


          • 2. Re: Renaming multiple instances on stage
            Ned Murphy Adobe Community Professional & MVP

            A word of warning... if the frames that these objects inhabit happen to be adjacent on the same layer you will probably find that despite changing their names, in running the file the buttons in the latter frame will inherit the names of their instances in the preceding frame.  You'll want to interupt any connection between them either by a blank frame or a different layer.

            1 person found this helpful
            • 3. Re: Renaming multiple instances on stage
              odgar Level 1

              Thanks so much for this. I'll keep an eye on how it goes and if I notice anything awry when it's run, I'll try this first as a fix :-)

               

              Cheers

               

              Alex