/* ItemsToCharacter - Aaron Steed Takes a list of selected items from the library and dumps them sequentially on the timeline of a new clip The new clip is formatted in such a manner as to create a state-machine animation which is the format of most characters in my games put the jsfl in: C:/Documents and Settings/user/Local Settings/Application Data/Adobe/Flash CS3/en/Configuration/Commands/ */ fl.outputPanel.clear(); var doc = fl.getDocumentDOM(); var lib = doc.library; var selectionList = lib.getSelectedItems().slice(); var name = prompt("Enter name of character clip: "); if(name != null && name.length > 0) { // create new item and set ready for export lib.addNewItem("movie clip", name); lib.selectItem(name); var clip = lib.getSelectedItems()[0]; clip.linkageExportForAS = true; clip.linkageClassName = name; clip.linkageExportInFirstFrame = true; // prep timeline lib.editItem(name); var timeline = doc.getTimeline(); timeline.setLayerProperty("name", "labels"); timeline.addNewLayer("actions", "normal", false); timeline.addNewLayer("clips", "normal", false); for(var i = 1; i < selectionList.length; i++){ timeline.setSelectedLayers(0); timeline.insertBlankKeyframe(i * 10); timeline.setSelectedLayers(2); timeline.insertBlankKeyframe(i * 10); } // neaten things up by filling out with blank frames at the end timeline.setSelectedLayers(0); timeline.insertBlankKeyframe(selectionList.length * 10); timeline.removeFrames(selectionList.length * 10); timeline.setSelectedLayers(1); timeline.insertBlankKeyframe(selectionList.length * 10); timeline.removeFrames(selectionList.length * 10); timeline.setSelectedLayers(2); timeline.insertBlankKeyframe(selectionList.length * 10); timeline.removeFrames(selectionList.length * 10); timeline.layers[1].frames[0].actionScript = "stop();"; // put items on stage sequentially at 10 frame intervals, labelling as we go for(var i = 0; i < selectionList.length; i++) { timeline.currentFrame = i * 10; timeline.layers[0].frames[i * 10].name = "_"+i; timeline.setSelectedLayers(2); doc.addItem({x:0, y:0}, selectionList[i]); doc.selectAll(); var inst = doc.selection[0]; doc.moveSelectionBy({x:-inst.left, y:-inst.top}); } }