Using flash, ever had to add a stop frame to the first and last frame of all your movieclips in the library?

This script will do so for you!

Definitely save your FLA first, and definitely keep a backup of it too – There’s no undoing here, unless you want to try and anti the code to undo it all…

Suggested method is to drag all your movieclips into a new movie, run the jsfl file, and drag your movies back into your working file.

Save the script below as addstops.jsfl or similar:

var len = fl.getDocumentDOM().library.items.length;
var i;

for (i=0; i < len; i++) {

	var item = fl.getDocumentDOM().library.items[ i ];	
	var itemtype = item.itemType;
	if ( itemtype == "movie clip" ) {

		var frames = item.timeline.layers[0].frames[0].duration;

		fl.trace( 'movie clip found: ' + i + ' with frames: ' +  frames );
		// would have thought layers[1] should be required next... but no
		item.timeline.layers[0].frames[0].actionScript = "stop();";
		item.timeline.insertKeyframe( 1 );
		item.timeline.insertKeyframe( frames - 1);
		item.timeline.layers[0].frames[ frames - 1 ].actionScript = "stop();";

many thanks to shane mcartney's work here.

Now... what do I do about a code blog... will this do?

« »