You need to rename multiple symbols in your Flash Pro Library, but you dont want to do it one by one.
Create a JSFL command that will rename multiple library symbols.
There may be times where you will need to rename multiple library symbols, whether it is because you were given an FLA that doesn't have symbol naming convention you would like to use, or you need to merge FLAs that have symbols with the same name but different contents.
In order to do this we can create JSFL commands.
First we will create a script to change the symbol names. The first JSFL below is to append (add to the end of) to the symbol names.
//declare variable for the text to add
var addText;
// Get the Selected Items
var selectedItems = fl.getDocumentDOM().library.getSelectedItems();
function appendLibraryNames()
{
// Check if the items are selected. If no items are selected, throw an alert.
// If items are selected, throw the prompt to add text.
if (selectedItems.length == 0)
{
alert("Please select 1 or more symbols in the library.");
} else if (selectedItems.length >= 1)
{
addText = prompt("Append selected symbol names with:");
changeLibraryNames();
}
}
// Change the names in the library
function changeLibraryNames()
{
var i;
// If you don't add any text, nothing will be added when OK is pressed.
// If text is present, cycle through all selected items and APPEND text
// to the end of the symbol names.
if (addText == null)
{
} else
{
for (i = 0; i < selectedItems.length; i++)
{
selectedItems[i].name = selectedItems[i].name + addText;
}
}
}
Save this JSFL as "AppendLibraryNames.jsfl" in the Javascript folder in your local Flash user configuration:
[USER] / [AppSupport] /Adobe/Flash CS5/en_US/Configuration/Javascript.
Next, create a new JSFL. This is the one that is run from the Commands menu:
fl.runScript(fl.configURI + 'Javascript/AppendLibraryNames.jsfl', 'appendLibraryNames'); // runscript(config dir + JSFL to run, the method in JSFL file to run);
Save this JSFL as "Append Library Names.jsfl" to the Commands folder in your local Flash user configuration:
[USER] / [AppSupport] /Adobe/Flash CS5/en_US/Configuration/Commands
Close both JSFLs.
Usage
In any Flash Pro Library, highlight multiple MCs. Go to Commands > Append Library Names. Type in the text to be added to the end of the symbol names and press OK. Your library symbol names will now be changed.
You can also prepend library names with the following script.
//declare variable for the text to add
var addText;
// Get the Selected Items
var selectedItems = fl.getDocumentDOM().library.getSelectedItems();
function prependLibraryNames()
{
// Check if the items are selected. If no items are selected, throw an alert.
// If items are selected, throw the prompt to add text.
if (selectedItems.length == 0)
{
alert("Please select 1 or more symbols in the library.");
} else if (selectedItems.length >= 1)
{
addText = prompt("Prepend selected symbol names with:");
changeLibraryNames();
}
}
// Change the names in the library
function changeLibraryNames()
{
var i;
// If you don't add any text, nothing will be added when OK is pressed.
// If text is present, cycle through all selected items and PREPEND text
// to the beginning of the symbol names.
if (addText == null)
{
} else
{
for (i = 0; i < selectedItems.length; i++)
{
selectedItems[i].name = addText + selectedItems[i].name;
}
}
}
Save this JSFL as "PrependLibraryNames.jsfl" in the Javascript folder in your local Flash user configuration:
[USER] / [AppSupport] /Adobe/Flash CS5/en_US/Configuration/Javascript.
Use this to run from the Commands menu:
fl.runScript(fl.configURI + 'Javascript/PrependLibraryNames.jsfl', 'prependLibraryNames'); // runscript(config dir + JSFL to run, the method in JSFL file to run);
Save this JSFL as "Prepend Library Names.jsfl" to the Commands folder in your local Flash user configuration:
[USER] / [AppSupport] /Adobe/Flash CS5/en_US/Configuration/Commands
These same files can be found in the ZIP below.
+