{"id":374,"date":"2009-12-16T00:20:01","date_gmt":"2009-12-15T14:20:01","guid":{"rendered":"http:\/\/www.filthmedia.com\/?p=374"},"modified":"2009-12-16T00:20:01","modified_gmt":"2009-12-15T14:20:01","slug":"jsfl-flash-add-stop-to-first-and-last-frame-of-all-movieclips","status":"publish","type":"post","link":"http:\/\/www.filthmedia.com\/?p=374","title":{"rendered":"JSFL + Flash. Add stop(); to first and last frame of all movieclips"},"content":{"rendered":"<p>Using flash, ever had to add a stop frame to the first and last frame of all your movieclips in the library?<\/p>\n<p>This script will do so for you!<\/p>\n<p>Definitely save your FLA first, and definitely keep a backup of it too &#8211; There&#8217;s no undoing here, unless you want to try and anti the code to undo it all&#8230;<\/p>\n<p>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.<\/p>\n<p>Save the script below as <i>addstops.jsfl<\/i> or similar:<\/p>\n<pre>\r\nvar len = fl.getDocumentDOM().library.items.length;\r\nvar i;\r\n\r\nfor (i=0; i < len; i++) {\r\n\r\n\tvar item = fl.getDocumentDOM().library.items[ i ];\t\r\n\tvar itemtype = item.itemType;\r\n\tif ( itemtype == \"movie clip\" ) {\r\n\r\n\t\tvar frames = item.timeline.layers[0].frames[0].duration;\r\n\r\n\t\tfl.trace( 'movie clip found: ' + i + ' with frames: ' +  frames );\r\n\t\r\n\t\titem.timeline.addNewLayer();\r\n\t\t\/\/ would have thought layers[1] should be required next... but no\r\n\t\titem.timeline.layers[0].frames[0].actionScript = \"stop();\";\r\n\t\titem.timeline.insertKeyframe( 1 );\r\n\t\titem.timeline.insertKeyframe( frames - 1);\r\n\t\titem.timeline.layers[0].frames[ frames - 1 ].actionScript = \"stop();\";\r\n\t\t\r\n\t}\r\n}\r\n<\/pre>\n<p>many thanks to shane mcartney's work <a href='http:\/\/www.lostinactionscript.com\/blog\/index.php\/2009\/04\/03\/export-layers-to-swf-with-jsfl\/'>here<\/a>.<\/p>\n<p>Now... what do I do about a code blog... will this do?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8211; There&#8217;s no undoing here, unless you want to try and anti the [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"http:\/\/www.filthmedia.com\/index.php?rest_route=\/wp\/v2\/posts\/374"}],"collection":[{"href":"http:\/\/www.filthmedia.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.filthmedia.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.filthmedia.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.filthmedia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=374"}],"version-history":[{"count":0,"href":"http:\/\/www.filthmedia.com\/index.php?rest_route=\/wp\/v2\/posts\/374\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.filthmedia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.filthmedia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=374"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.filthmedia.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}