views:

3757

answers:

7

Right now in Flash CS3 and up (using Actionscript 3) if you have the same instance that is used in multiple keyframes in a layer, and you decide to assign or change the instance name later, you would have to go to each keyframe and set the instance name. This is a big nuisance. Is there a quicker or better way to do this?

NOTE: In AS2, you can set the name by using name property of the MovieClip in your code in the onLoad handler of the MovieClip class so it's done once and for all. Unfortunately in AS3, you are not allowed to set the name property anymore.

A: 

Name your instances before copying them to multiple keyframes! (before pressing F6 - Insert New Keyframe) That's always the best solution.

Jenko
I agree naming first is the best approach, my question is mostly for times when you have to change or when you forgot to name something that you later want to refer to in code.
Boon
+1  A: 

A semi-automatic way of finding and replacing instance names would be:

  1. Flash main menu > Edit > Find and Replace (CTRL+F)
  2. Search in "Current Document"
  3. For "Symbol"
  4. Name [your instance's symbol]
  5. Ensure that Live Edit is UNchecked.
  6. Write down your new instance name someplace, then copy it to clipboard.

Repeat the following per instance:

  1. Press Find Next on the Find and Replace panel
  2. Double-click the Instance Name textfield in the Properties panel, to select All
  3. Paste your new instance name, overwriting the original
  4. Press ENTER to commit your change.

Have fun! That's the best way using the tools within the Flash IDE

Jenko
A: 

if all of the instance frames is serial, you just assign the name in first of that. else 'finding and replacing instance names' maybe the best solution.

+4  A: 

You can use JSFL, a javascript-based automation lanaguage in Flash, to automate tasks like this.

  • Click File > New
  • Select "Flash JavaScript File" from the list
  • Paste the following script
  • Make sure you have your instances selected in your FLA file
  • Click the Run (Play) button in your JSFL script file

You can then use the following code to name all selected instances with a prefix and an an index number:

var prefix:String = "myInstance_";
for(i in fl.getDocumentDOM().selection)
{
    fl.getDocumentDOM().selection[i].name = prefix + i.toString();
}

This will result in your instances being named myInstance_1, myInstance_2, etc. This is mainly an example for you to extend to your specific needs.

(One thing to note fl.trace() is how you print trace messages in JSFL when you're debugging, took me a while to figure that out)

Soviut
Aye, this is what you should be looking at. Don't forget that you can go into multiple-frame-editing mode to select the same MC in multiple keyframes.
fenomas
My example was meant to be a a quick one off solution and a primer for future JSFL developing, in case the need for a renamer was needed more often.
Soviut
How would you make your script comb through everything in a layer and set the name for all keyframe instances? since in standard practice we usually only have one movieclip instance per layer.
Boon
Post that as a separate question and I can answer it there. Essentially you'd use layers = fl.getDocumentDOM().getTimeline().layers, then you can iterate over the layers like an array (layers[0], layers[1], etc.) and get layers.frames, and iterate those like an array too.
Soviut
Great! I wasn't really sure whether JSFL could do this kinda thing.
Jenko
Think of JSFL as actionscript for the Flash application itself.
Soviut
A: 

the best way to change multiply frame ( but not the most conman )

  1. select all the frame in your that time line
  2. click the button "Edit multiply frame"
    this button is just below the time line near the onion skin

  3. change the instance name

this will change your instance name for all the frame

Shvilam
A: 

thank you for sharing

sharedtut
A: 

This extension will set the instance name over multiple keyframes: http://ajarproductions.com/blog/2010/03/30/set-instance-name-on-multiple-frames/

Justin_P