PDA

View Full Version : renaming library items - taking off last four characters


Seanx
07-21-2006, 08:22 PM
Mooska was helping me with this problem and gave me the following code:

var items = fl.getDocumentDOM().library.items;

for (var i=0; i<items.length; i++)
{
var pos = items[i].name.indexOf( " - C" );
if ( pos != -1 )
{
items[i].name = items[i].name.slice( 0, pos );
}
alert( items[i].name );
}
//

Which as you can see removes a " - C" from each library item.

An gray exclamation point box pops up with the new title of the button in it and for each button you have to click ok.

The problem is that sometimes I click through all 200 or 700 oks and then look in the library and none of the buttons are changed. On some movies I have movie clips with " - E" or " - D" at the end - and of course I'd open the jsfl and change the " - C" to match. I think the first time I noticed the problem was when I tried to run this on an fla that had some buttons with " - C" and some with " - E" - since then I never can tell whether it will work in a given fla. It doesn't seem to make sense.

Also - is there some way to make it so I don't have to push ok a few hundred times? I don't really mind, but it's irritating when the code doesn't rename the library items. I tried taking this line out:

alert( items[i].name );

but it didn't seem to have any effect.

Seanx
07-21-2006, 08:27 PM
nevermind....Hhhh...

In writing the post's last line I noticed one thing - the line:

alert( items[i].name );

and realized that I should try not taking the whole line out - but just taking the 'alert' out

now it works fine... viola.