├── README.md
├── commands
├── [mm] Bitmap Selection to MovieClips.jsfl
├── [mm] Check Flump library.jsfl
├── [mm] Check for empty clips in library.jsfl
├── [mm] Compile All.jsfl
├── [mm] Create labels.jsfl
├── [mm] Duplicate advanced.jsfl
├── [mm] Flump files in directory.jsfl
├── [mm] Frame to left.jsfl
├── [mm] Frame to right.jsfl
├── [mm] Log framelabels.jsfl
├── [mm] Log instance names - getChildByName.jsfl
├── [mm] Log instance names.jsfl
├── [mm] Multiple library rename.jsfl
├── [mm] Multiple selection rename.jsfl
├── [mm] Name it right!.jsfl
├── [mm] Organize layers.jsfl
├── [mm] Organize library.jsfl
├── [mm] Random instance swapper.jsfl
├── [mm] Random rotation.jsfl
├── [mm] Rename across layer.jsfl
├── [mm] Rename library items.jsfl
├── [mm] Selected Library Items to MovieClips.jsfl
├── [mm] Selected Library Items to Sprites.jsfl
├── [mm] Selection to MovieClips.jsfl
├── [mm] Snap Selection to pixel.jsfl
├── [mm] Snap to pixel.jsfl
└── [mm] Transform selection manager.jsfl
└── images
├── autorenamelayer-explanation.jpg
├── duplicate-advanced.gif
├── loginstancenames-explanation.jpg
├── nameitright-explanation.jpg
└── selectiontransformmanager-explanation.jpg
/README.md:
--------------------------------------------------------------------------------
1 | # JSFL scripts
2 | > For Adobe Flash CS4, CS5, CS6 and CC / Adobe Animate CC
3 |
4 | ### Introduction
5 |
6 | This is a place for sharing of Flash productivity tools, to work faster, better, well-organized and highly efficient. These tools are also known as Flash extensions, commands or JSFL files.
7 |
8 | ### The tools
9 |
10 | * Library tools
11 | * Duplicate advanced - Deep copies timelines
12 | * Name it right! - Better alternative for 'symbol properties' window
13 | * Organize library - places all images/videos in folders
14 | * Selected Library Items to MovieClips
15 | * Selected Library Items to Sprites
16 | * Multiple library rename
17 | * Selection tools
18 | * Transform selection manager - Apply (ralative/absolute) transformation on multiple objects
19 | * Selection to MovieClips
20 | * Bitmap Selection to MovieClips
21 | * Snap Selection to pixel
22 | * Multiple selection rename
23 | * Random rotation
24 | * Timeline tools
25 | * Organize layers - auto renames all layers / cleans up empty layers
26 | * Rename across layer
27 | * Frame to left
28 | * Frame to right
29 | * Random instance swapper
30 | * Create labels
31 | * Coding helper tools
32 | * Log framelabels
33 | * Log instance names - getChildByName
34 | * Log instance names
35 | * Document tools
36 | * Compile All (open documents)
37 |
38 | Some of the tools are explained in [these blogposts](http://blog.stroep.nl/category/jsfl-2/)
39 |
40 | ### How to install jsfl files
41 |
42 | Copy the .jsfl files to this folder on your computer:
43 |
44 | #### Windows 7:
45 | `C:\Users\%USERNAME%\AppData\Local\Adobe\Flash CC\en_US\Configuration\Commands`
46 |
47 | #### Windows Vista:
48 | `C:\Users\%USERNAME%\Local Settings\Application Data\Adobe\Flash CC\en_US\Configuration\Commands`
49 |
50 | #### Windows XP:
51 | `C:\Documents and Settings\%USERNAME%\Local Settings\Application Data\Adobe\Flash CC\en_US\Configuration\Commands`
52 |
53 | #### Mac OS X:
54 | `C:/Users/%USERNAME%/Library/Application Support/Adobe/Flash CC/en_US/Configuration/Commands`
55 |
56 | ### Disclaimer
57 |
58 | Not all tools seem to work in Flash CC.
59 |
--------------------------------------------------------------------------------
/commands/[mm] Bitmap Selection to MovieClips.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Bitmap Selection to MovieClips
3 | * @version 1
4 | * @author: Mediamonks - http://www.mediamonks.com
5 | * @author: Mark Knol - http://blog.stroep.nl
6 | */
7 |
8 | fl.outputPanel.clear();
9 |
10 | var doc = fl.getDocumentDOM();
11 |
12 | if (!doc)
13 | {
14 | alert("Please open or create a flashfile.");
15 | }
16 | else
17 | {
18 | SelectionToMovieClips();
19 | }
20 |
21 | function SelectionToMovieClips()
22 | {
23 | var selectedItems = doc.selection;
24 |
25 | if (!selectedItems || !selectedItems.length)
26 | {
27 | alert('Select at least 1 item on stage')
28 | return;
29 | }
30 |
31 | var alignments = ["top left", "top center", "top right", "center left", "center", "center right", "bottom left", "bottom center", "bottom right"];
32 |
33 | //var prefix = prompt('Enter new name (prefix):', '')
34 | var dialogXML = ''
35 |
36 | dialogXML += '';
37 |
38 | dialogXML += ''
39 | for (var i =0;i'
40 | dialogXML += ''
41 |
42 | var dialogData = createDialogXML(dialogXML)
43 |
44 | if (dialogData && dialogData.alignment)
45 | {
46 | var dom = fl.getDocumentDOM();
47 | var library = dom.library;
48 |
49 | var count = 1;
50 |
51 | for each(var selectedItem in selectedItems)
52 | {
53 | fl.getDocumentDOM().selectNone();
54 |
55 | selectedItem.selected = true;
56 |
57 | var newName = selectedItem.libraryItem.name.split("/").pop().split(".png").shift().split(".jpeg").shift().split(".jpg").shift().split(".gif").shift();
58 | dom.convertToSymbol("movie clip", newName, dialogData.alignment);
59 |
60 | var newLibraryIndex = dom.library.findItemIndex(newName);
61 | var newLibraryItem = dom.library.items[newLibraryIndex];
62 | setAsSprite(newLibraryItem);
63 |
64 | count ++
65 | selectedItem.selected = false;
66 |
67 | }
68 | }
69 |
70 | function createDialogXML(xmlString, description)
71 | {
72 | var dialogXML = '';
77 |
78 | var url = fl.configURI + '/Commands/temp-dialog-' + parseInt(Math.random() * 777 * 777) + '.xml';
79 | FLfile.write(url, dialogXML);
80 |
81 | var panelOutput = fl.getDocumentDOM().xmlPanel(url);
82 |
83 | FLfile.remove(url);
84 |
85 | return panelOutput;
86 | }
87 |
88 | function setAsSprite(item)
89 | {
90 | item.linkageExportForAS = true;
91 | item.name = item.name.split("/").pop().split("-").join("_").split(" ").join("_");
92 | item.linkageClassName = item.name.split("/").pop();
93 | item.linkageBaseClass = "flash.display.Sprite";
94 | item.linkageExportInFirstFrame = true;
95 | }
96 |
97 | function getClassPackageName()
98 | {
99 | var retval = doc.name.toLowerCase().split('.fla')[0].split('.xfl')[0];
100 | if (retval) retval = retval.split('..').join('.').split(' ').join('').split('-').join('_').toLowerCase();
101 | return retval;
102 | }
103 | }
104 |
105 | var scriptPath = FLfile.uriToPlatformPath(fl.scriptURI);
106 | var scriptPathEnd = scriptPath.lastIndexOf("\\");
107 | scriptPath = scriptPath.slice(0, scriptPathEnd + 1);
108 | fl.runScript(FLfile.platformPathToURI(scriptPath + "[mm] Organize library.jsfl"));
109 | fl.runScript(FLfile.platformPathToURI(scriptPath + "[mm] Check Flump library.jsfl"));
110 |
--------------------------------------------------------------------------------
/commands/[mm] Check Flump library.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Flump ready FLA checks + fixes
3 |
4 | * @author: Mediamonks - http://www.mediamonks.com
5 | * @author: Mark Knol - http://blog.stroep.nl
6 | */
7 |
8 | fl.outputPanel.clear();
9 |
10 | var doc = fl.getDocumentDOM();
11 |
12 | ConfigureLibrary();
13 |
14 | function ConfigureLibrary()
15 | {
16 | var smooth = confirm("Make smooth?");
17 | var pixelate = false;
18 | if (!smooth) pixelate = confirm("Make pixelated?");
19 |
20 | var libraryItems = fl.getDocumentDOM().library.items;
21 | var completed = [];
22 | for (var i = libraryItems.length - 1; i >= 0; i--)
23 | {
24 | var item = libraryItems[i];
25 | if (item.itemType == "bitmap")
26 | {
27 | completed.length = 0;
28 | if (smooth) {
29 | if (!item.allowSmoothing)
30 | {
31 | item.allowSmoothing = true;
32 | completed.push("smooth");
33 | }
34 | }
35 | if (pixelate) {
36 | if (item.allowSmoothing)
37 | {
38 | item.allowSmoothing = false;
39 | completed.push("pixelated");
40 | }
41 | }
42 |
43 | if (item.compressionType != "lossless")
44 | {
45 | item.compressionType = "lossless";
46 | completed.push("lossless");
47 | }
48 | if (completed.length > 0) fl.trace(item.name + " now " + completed.join(" and "));
49 | }
50 | }
51 | fl.trace("-- Configuring library done");
52 | }
53 |
--------------------------------------------------------------------------------
/commands/[mm] Check for empty clips in library.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Check for empty clips in library
3 |
4 | * @author: Mediamonks - http://www.mediamonks.com
5 | * @author: Mark Knol - http://blog.stroep.nl
6 | */
7 |
8 | fl.outputPanel.clear();
9 |
10 | var doc = fl.getDocumentDOM();
11 |
12 | FindEmptyClipsInLibrary();
13 |
14 | function FindEmptyClipsInLibrary()
15 | {
16 | var foundSomething = false;
17 | var libraryItems = fl.getDocumentDOM().library.items;
18 | var completed = [];
19 | for (var i = libraryItems.length - 1; i >= 0; i--) {
20 | var item = libraryItems[i];
21 | if (item.timeline) {
22 | var hasItems = false;
23 |
24 | var layers = item.timeline.layers;
25 | loop1:
26 | for (var j=0; j < layers.length; j++) {
27 | var layer = layers[j];
28 | if (layer.layerType == "normal" || layer.layerType == "mask" || layer.layerType == "masked") {
29 | var frames = layer.frames;
30 | loop2:
31 | for (var k=0; k"
dialog += '';
if (i%DOCUMENTS_PER_ROW==DOCUMENTS_PER_ROW-1) dialog += ""
}
var settingsData = createDialogXML(dialog);
if (settingsData.dismiss == 'accept')
{
for (var name in settingsData)
{
if (settingsData[name] == "true")
{
var index = parseInt(name.split(DOC_PREFIX).join(""));
var doc = docs[index];
doc.publish();
var saveFileURI = fl.configURI + doc.name + ".errors"
fl.compilerErrors.save(saveFileURI);
var contents = FLfile.read(saveFileURI);
FLfile.remove(saveFileURI);
if (contents.split("\n").length > 1 || contents.split("\r").length > 1)
{
log += (doc.name + " publish error!\n" );
errorLog += contents;
success = false;
break;
}
else
{
log += (doc.name + " published\n");
totalPublishedDocs++;
}
totalSelectedDocs ++;
}
}
log += ("\n\n***************************************************\nTotal movies published: " + totalPublishedDocs + "/" + totalSelectedDocs + " selected documents");
if (success == false) { log += "\n***************************************************\n\nErrors: " + errorLog; }
fl.outputPanel.trace(log);
}
function createDialogXML(xmlString, description)
{
var dialogXML = '';
var localConfigURI = fl.configURI;
// Verify that the provided path ends with ‘/’
if (localConfigURI.charAt(localConfigURI.length – 1) != "/") localConfigURI = localConfigURI + "/";
var path = localConfigURI + "Commands/.dialog-" + parseInt(Math.random() * 1000) + ".xml"
FLfile.write(path, xmlString);
var xmlPanelOutput = fl.getDocumentDOM().xmlPanel(path);
FLfile.remove(path);
return xmlPanelOutput;
}
--------------------------------------------------------------------------------
/commands/[mm] Create labels.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Adds a new layer with frame labels.
3 | * @version 1
4 | * @author: Mediamonks - http://www.mediamonks.com
5 | * @author: Mark Knol - http://blog.stroep.nl
6 | */
7 |
8 | var predefinedLabels = ["in out","show hide","up in over down out","over in over out","down press down release","selected select selected deselect","disabled disable disabled enable", "focus focus focused blur", "over in over out down press down release selected select selected deselect disabled disable disabled enable focus focus focused blur"];
9 | var defaultLabelIndex = 2;
10 |
11 | var doc = fl.getDocumentDOM();
12 |
13 | if (!doc)
14 | {
15 | alert("Please open or create a flashfile.");
16 | }
17 | else
18 | {
19 | CreateLabels();
20 | }
21 |
22 | function CreateLabels()
23 | {
24 | var dialogXML = '';
25 | dialogXML += ''
26 |
27 | dialogXML += ''
28 | for (var i=0;i'
29 | dialogXML += ''
30 |
31 | dialogXML += ''
32 | dialogXML += ''
33 | for (var i=1;i<=25;i++) dialogXML += ''
34 | dialogXML += ''
35 |
36 | var data = createDialogXML(dialogXML);
37 | var timeline = doc.getTimeline();
38 |
39 | if (data && data.names && data.frameSpace)
40 | {
41 | var labelNames = data.names.split(" ");
42 | var space = Number(data.frameSpace);
43 | var layerIndex = timeline.addNewLayer("labels", "normal", true);
44 | var layer = timeline.layers[layerIndex];
45 | while (layer.frames.length < labelNames.length * space)
46 | {
47 | timeline.insertFrames(1, false, 0);
48 | }
49 | var i = 0;
50 | for (var frameIndex = 0; frameIndex < labelNames.length * space; frameIndex += space)
51 | {
52 | if (frameIndex != 0) timeline.insertKeyframe(frameIndex);
53 | layer.frames[frameIndex].name = labelNames[i];
54 | i++;
55 |
56 | }
57 | layer.color = 0xF21743;
58 | }
59 | }
60 |
61 | function createDialogXML(xmlString)
62 | {
63 | var dialogXML = '';
66 |
67 |
68 | var localConfigURI = fl.configURI;
69 | // Verify that the provided path ends with ‘/’
70 | if (localConfigURI.charAt(localConfigURI.length – 1) != "/") localConfigURI = localConfigURI + "/";
71 |
72 | var path = localConfigURI + "Commands/.dialog-" + parseInt(Math.random() * 1000) + ".xml"
73 | FLfile.write(path, xmlString);
74 | var xmlPanelOutput = fl.getDocumentDOM().xmlPanel(path);
75 | FLfile.remove(path);
76 | return xmlPanelOutput;
77 | }
--------------------------------------------------------------------------------
/commands/[mm] Duplicate advanced.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Deep Duplicate tool
3 | * @version 1.0
4 | * @author: Mark Knol - http://blog.stroep.nl
5 | */
6 |
7 | var doc = fl.getDocumentDOM();
8 | var INSTANCE = "instance";
9 | var SYMBOL = "symbol";
10 | var BITMAP = "bitmap";
11 |
12 | if (!doc)
13 | {
14 | alert("Please open or create a flashfile.");
15 | }
16 | else
17 | {
18 | DuplicateAdvanced();
19 | }
20 |
21 | function DuplicateAdvanced()
22 | {
23 | var selectedItems = doc.selection;
24 | var library = fl.getDocumentDOM().library;
25 | var items = library.getSelectedItems();
26 | var item;
27 | if (items.length == 1)
28 | {
29 | item = items[0];
30 | }
31 | if (!item)
32 | {
33 | if (items.length == 0)
34 | {
35 | var items = fl.getDocumentDOM().selection;
36 | if (items.length == 1)
37 | {
38 | item = items[0].libraryItem;
39 | }
40 | }
41 | }
42 | if (!item)
43 | {
44 | alert("Select one item on stage or in your library to do the magic");
45 | return;
46 | }
47 | var usedFolder = false;
48 |
49 | var dialogXML = '';
50 |
51 | var libraryNames = findNamesRecursive(item);
52 | libraryNames.sort(function(a,b) { return a>b?-1:1 })
53 |
54 | if (libraryNames && libraryNames.length)
55 | {
56 | dialogXML += ''
57 | var index = 0;
58 | for (var a in libraryNames)
59 | {
60 | if (libraryNames.length >= 8 && index % 4 == 0) dialogXML += '';
61 |
62 | var libraryName = libraryNames[a];
63 |
64 | dialogXML += '';
65 |
66 | if (libraryNames.length >= 8 && index % 4 == 3) dialogXML += '';
67 | index++;
68 | }
69 |
70 | if (libraryNames.length >= 8 && (index - 1) % 4 < 3) dialogXML += ''; // make sure its closed
71 |
72 | //oncommand="this.fl.xmlui.setEnabled(\'replaceFrom1\',false);this.o=\'\';for(a in fl) {this.o+=a+\':\'+fl[a]+\'\\n\'};alert(this.o);"
73 |
74 | dialogXML += ''
75 | dialogXML += '';
76 | dialogXML += ''
77 | dialogXML += '';
78 | dialogXML += '';
79 | dialogXML += '';
80 | dialogXML += ''
81 | dialogXML += ''
82 | }
83 | var data;
84 |
85 | if (libraryNames && libraryNames.length)
86 | {
87 | data = createDialogXML(dialogXML, "Duplicate Advanced - Library Symbol - " + item.name);
88 | if (data.dismiss === 'accept')
89 | {
90 | if (!data.prefix && !data.postfix && !(data.replaceFrom1 || data.replaceFrom2 || data.replaceFrom3))
91 | {
92 | if (confirm("Paupert! Enter name pre- or postfix or replacement")) alert("I mean the next time you run this tool, ofcourse. So.. try again.");
93 | return;
94 | }
95 |
96 | var selectedItemsCount = 0
97 | for(var id in data) { if (id.indexOf('checkbox_') > -1) selectedItemsCount ++}
98 | if (selectedItemsCount > 20)
99 | {
100 | if (!confirm("Hmm.. you've selected a lot of symbols.. It could take a while. I hope you have saved. Give it a try anyway?")) return;
101 | }
102 |
103 | var replaces = [/*{from:item.name, to: data.prefix + item.name.split(data.replaceFrom1).join(data.replaceTo1).split(data.replaceFrom2).join(data.replaceTo2).split(data.replaceFrom3).join(data.replaceTo3) + data.postfix}*/];
104 |
105 | for(var id in data)
106 | {
107 | if (id.indexOf('checkbox_') > -1)
108 | {
109 | var originalLibraryName = id.split('checkbox_').join('');
110 | var newName = data.prefix + originalLibraryName.split("/").pop().split(data.replaceFrom1).join(data.replaceTo1).split(data.replaceFrom2).join(data.replaceTo2).split(data.replaceFrom3).join(data.replaceTo3) + data.postfix;
111 | if (data[id] === 'true') // checkbox checked, sad it's a string
112 | {
113 | var libraryItem = getLibraryItem(originalLibraryName);
114 |
115 | fl.getDocumentDOM().library.duplicateItem(originalLibraryName);
116 |
117 | var convertedName = originalLibraryName.split("/").pop();
118 | var newLibraryItem = getLibraryItem(convertedName + " copy") || getLibraryItem(originalLibraryName + " copy"); // Hacky way to find new symbol
119 | //alert(originalLibraryName + " > " + newName);
120 | newLibraryItem.name = newName;
121 |
122 | replaces.push({from: originalLibraryName, to: newLibraryItem.name});
123 |
124 | copyClassInfo(libraryItem, newLibraryItem, data.persistExportRS === 'true');
125 |
126 | // apply replacement on linkage class name
127 | if (newLibraryItem.linkageExportForAS == true)
128 | {
129 | newLibraryItem.linkageClassName = newLibraryItem.linkageClassName.split(data.replaceFrom1).join(data.replaceTo1).split(data.replaceFrom2).join(data.replaceTo2).split(data.replaceFrom3).join(data.replaceTo3)
130 | }
131 | }
132 | }
133 | }
134 |
135 | var leni = replaces.length;
136 |
137 | // loop through all selected movieclips' keyframes/elements, and swap with those who are selected
138 | for(var i = 0, leni = replaces.length; i < leni; i++)
139 | {
140 | var replaceItem = getLibraryItem(replaces[i].to);
141 | //alert(replaces[i].from + " >> " + replaces[i].to);
142 | if (!replaceItem || !replaceItem.timeline) return;
143 |
144 | for each(var layer in replaceItem.timeline.layers)
145 | {
146 | var frameNumber = 0;
147 | for each(var frame in layer.frames)
148 | {
149 | if (frameNumber === layer.frames[frameNumber].startFrame) // keyframes only
150 | {
151 | for each(var element in frame.elements)
152 | {
153 | if (element.elementType === INSTANCE && element.libraryItem)
154 | {
155 | for (var j = leni - 1; j >= 0; j--)
156 | {
157 | var replaceJ = replaces[j];
158 | var originalLibraryItem = getLibraryItem(replaceJ.from);
159 |
160 | if (element.libraryItem.name === originalLibraryItem.name)
161 | {
162 | var targetLibraryItem = getLibraryItem(replaceJ.to);
163 | if (targetLibraryItem)
164 | {
165 | element.libraryItem = targetLibraryItem;
166 | }
167 | }
168 | }
169 | }
170 | }
171 | }
172 | frameNumber++;
173 | }
174 | }
175 | }
176 | }
177 | }
178 | else
179 | {
180 | alert("You have not selected anything to duplicate. Nothing will happen.");
181 | }
182 |
183 | function getLibraryItem(name)
184 | {
185 | for each(var item in library.items)
186 | {
187 | if (item.name === name) return item;
188 | }
189 | }
190 | }
191 |
192 | function copyClassInfo(fromLibraryItem, toLibraryItem, persistExportRS)
193 | {
194 | if (toLibraryItem == fromLibraryItem) return;
195 | var linkageClassName
196 | if (fromLibraryItem.linkageImportForRS) // remember linkageClassName before turning 'linkageImportForRS' off
197 | {
198 | linkageClassName = fromLibraryItem.linkageClassName;
199 | }
200 | if (toLibraryItem.linkageImportForRS) toLibraryItem.linkageImportForRS = false;
201 | if (toLibraryItem.linkageExportForRS) toLibraryItem.linkageExportForRS = false;
202 |
203 | if (toLibraryItem && fromLibraryItem && (fromLibraryItem.linkageExportForAS || fromLibraryItem.linkageImportForRS))
204 | {
205 | toLibraryItem.linkageExportForAS = true;
206 | toLibraryItem.linkageClassName = linkageClassName ? linkageClassName.split(fromLibraryItem.name).join(toLibraryItem.name) : fromLibraryItem.linkageClassName.split(fromLibraryItem.name).join(toLibraryItem.name);
207 | toLibraryItem.linkageBaseClass = fromLibraryItem.linkageBaseClass;
208 | toLibraryItem.linkageExportInFirstFrame = fromLibraryItem.linkageExportInFirstFrame;
209 | toLibraryItem.linkageExportForRS = persistExportRS ? (fromLibraryItem.linkageImportForRS ? false : fromLibraryItem.linkageExportForRS) : false;
210 | }
211 | }
212 |
213 | function findNamesRecursive(item, list)
214 | {
215 | if (!list) list = (item.name.indexOf("'") == -1 && item.name.indexOf('<') == -1 && item.name.indexOf('>') == -1 && item.name.indexOf('"') == -1) ? [item.name] : [];
216 | if (!item.timeline) return list;
217 | for each (var layer in item.timeline.layers)
218 | {
219 | for each(var frame in layer.frames)
220 | {
221 | for each(var element in frame.elements)
222 | {
223 | if (element.elementType === INSTANCE && element.instanceType === SYMBOL)
224 | {
225 | if (list.indexOf(element.libraryItem.name) == -1)
226 | {
227 | var libraryName = element.libraryItem.name
228 | if (libraryName.indexOf("'") == -1 && libraryName.indexOf('<') == -1 && libraryName.indexOf('>') == -1 && libraryName.indexOf('"') == -1)
229 | {
230 | list.push(libraryName);
231 | list = findNamesRecursive(element.libraryItem, list);
232 | }
233 | }
234 | }
235 | }
236 | }
237 | }
238 | return list;
239 | }
240 |
241 | function createDialogXML(xmlString, title)
242 | {
243 | var dialogXML = '';
246 |
247 | var url = fl.configURI + '/Commands/temp-dialog-' + parseInt(Math.random() * 777 * 777) + '.xml';
248 | FLfile.write(url, dialogXML);
249 |
250 | var panelOutput = fl.getDocumentDOM().xmlPanel(url);
251 |
252 | FLfile.remove(url);
253 |
254 | return panelOutput;
255 | }
--------------------------------------------------------------------------------
/commands/[mm] Flump files in directory.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Runs all flump files in directory of current file
3 | * @author: Mediamonks - http://www.mediamonks.com
4 | * @author: Mark Knol - http://blog.stroep.nl
5 | */
6 | var pathToFlump = "C:\\Program Files (x86)\\Flump\\Flump.exe";
7 | var doc = fl.getDocumentDOM();
8 | var directory = getDirectory(doc);
9 | var files = FLfile.listFolder(directory + "*.flump");
10 | for(var i=0; i 0)
{
timeline.removeFrames(timeline.currentFrame - 1);
timeline.insertFrames(1, false, timeline.currentFrame);
}
}
--------------------------------------------------------------------------------
/commands/[mm] Frame to right.jsfl:
--------------------------------------------------------------------------------
1 | /**
* Frame to right
*
* @author: Mediamonks - http://www.mediamonks.com
* @author: Mark Knol - http://blog.stroep.nl
*/
var doc = fl.getDocumentDOM();
var timeline = fl.getDocumentDOM().getTimeline();
if (!doc)
{
alert("Please open or create a flashfile.");
}
else
{
FrameToRight();
}
function FrameToRight()
{
if (timeline.currentFrame < timeline.frameCount - 1)
{
timeline.removeFrames(timeline.currentFrame);
timeline.insertFrames(1, false, timeline.currentFrame-1);
timeline.setSelectedFrames(timeline.currentFrame+2, timeline.currentFrame+3);
}
}
--------------------------------------------------------------------------------
/commands/[mm] Log framelabels.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Scans the current timeline and outputs frame labels in several copy/pastable formats
3 | *
4 | * @author: Mediamonks - http://www.mediamonks.com
5 | * @author: Mark Knol - http://blog.stroep.nl
6 | */
7 |
8 | fl.outputPanel.clear();
9 |
10 | var items;
11 | var doc = fl.getDocumentDOM();
12 |
13 | var TEMPLATE1 = "\t\tpublic static const {LABEL}:String = \"{label}\";";
14 |
15 | if (!doc)
16 | {
17 | alert("Please open or create a flashfile.");
18 | }
19 | else
20 | {
21 | LogInstanceNames();
22 | }
23 |
24 | function LogInstanceNames()
25 | {
26 | var timeline = doc.getTimeline();
27 | var layer, frame, elem, cls;
28 | var arr1 = [];
29 | var arr2 = [];
30 | var vars;
31 |
32 | // go through all frames in all layers and search for instance variables.
33 | for (var i = 0, leni = timeline.layers.length; i < leni; i++)
34 | {
35 | layer = timeline.layers[i];
36 |
37 | if (layer.layerType === "guide" || layer.layerType === "guided" || layer.layerType === "folder") continue;
38 |
39 | for (var j = 0, lenj = layer.frames.length; j < lenj; j++)
40 | {
41 | frame = layer.frames[j];
42 | if(frame.startFrame == j && frame.name)
43 | {
44 | arr1.push(replaceVars(TEMPLATE1, {label:frame.name,LABEL:frame.name.toUpperCase()}));
45 | arr2.push(frame.name);
46 | }
47 | }
48 | }
49 |
50 | function replaceVars(template, vars)
51 | {
52 | for (var value in vars)
53 | {
54 | template = template.split("{"+value+"}").join(vars[value]);
55 | }
56 | return template;
57 | }
58 |
59 | if (arr2.length > 0)
60 | {
61 | var output1 = (arr1).join("\n");
62 | output1 = output1.substr(2, output1.length); // remove first 2 tabs for nice copy / paste
63 | fl.trace((arr2).join(", ") + "\n\n\""+ (arr2).join("\", \"") + "\"\n\n"+ output1);
64 | }
65 | else
66 | {
67 | fl.trace('no labels found');
68 | }
69 |
70 | function unique(arr)
71 | {
72 | var a = [];
73 | var l = arr.length;
74 | for(var i = 0; i < l; i++)
75 | {
76 | for(var j = i + 1; j < l; j++)
77 | {
78 | if (arr[i] === arr[j]) j = ++i;
79 | }
80 | a.push(arr[i]);
81 | }
82 | return a;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/commands/[mm] Log instance names - getChildByName.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Scans the current timeline and outputs variable definitions for instance variables to the output window. The getChildByName-way.
3 | *
4 | * Original by http://code.google.com/p/fueljsfl
5 | * @author: Mediamonks - http://www.mediamonks.com
6 | * @author: Mark Knol - http://blog.stroep.nl
7 | */
8 |
9 | fl.outputPanel.clear();
10 |
11 | var items;
12 | var doc = fl.getDocumentDOM();
13 |
14 | var TEMPLATE1 = "\t\tprivate var _{variableName}:{className};";
15 | var TEMPLATE2 = "\t\t_{variableName} = {className}(this.getChildByName(\"{variableName}\"));";
16 |
17 | if (!doc)
18 | {
19 | alert("Please open or create a flashfile.");
20 | }
21 | else
22 | {
23 | LogInstanceNames();
24 | }
25 |
26 | function LogInstanceNames()
27 | {
28 | var timeline = doc.getTimeline();
29 | var layer, frame, elem, cls;
30 | var arr1 = [];
31 | var arr2 = [];
32 | var vars;
33 |
34 | // go through all frames in all layers and search for instance variables.
35 | for (var i = 0, leni = timeline.layers.length; i < leni; i++)
36 | {
37 | layer = timeline.layers[i];
38 |
39 | if (layer.layerType === "guide" || layer.layerType === "guided" || layer.layerType === "folder") continue;
40 |
41 | for (var j = 0, lenj = layer.frames.length; j < lenj; j++)
42 | {
43 | frame = layer.frames[j];
44 | if (j == frame.startFrame) // keyframes only
45 | {
46 | for (var k = 0, lenk = frame.elements.length; k < lenk; k++)
47 | {
48 | elem = frame.elements[k];
49 |
50 | if (elem.elementType == "text" && elem.name)
51 | {
52 | vars = {variableName:elem.name, className:"TextField"};
53 | arr1.push(replaceVars(TEMPLATE1, vars));
54 | arr2.push(replaceVars(TEMPLATE2, vars));
55 | continue;
56 | }
57 |
58 | if (!elem.libraryItem) continue;
59 |
60 | if (elem.libraryItem.linkageClassName || elem.libraryItem.linkageBaseClass)
61 | {
62 | if (elem.libraryItem.linkageBaseClass && elem.name)
63 | {
64 | cls = elem.libraryItem.linkageBaseClass.split(".").pop();
65 | vars = {variableName:elem.name, className:cls};
66 | arr1.push(replaceVars(TEMPLATE1, vars));
67 | arr2.push(replaceVars(TEMPLATE2, vars));
68 | }
69 | else if (elem.libraryItem.linkageClassName && elem.name)
70 | {
71 | cls = elem.libraryItem.linkageClassName.split(".").pop();
72 | vars = {variableName:elem.name, className:cls};
73 | arr1.push(replaceVars(TEMPLATE1, vars));
74 | arr2.push(replaceVars(TEMPLATE2, vars));
75 | }
76 | }
77 | else if (elem.name)
78 | {
79 | vars = {variableName:elem.name, className:"MovieClip"};
80 | arr1.push(replaceVars(TEMPLATE1, vars));
81 | arr2.push(replaceVars(TEMPLATE2, vars));
82 | }
83 | }
84 | }
85 | }
86 | }
87 |
88 | function replaceVars(template, vars)
89 | {
90 | for (var value in vars)
91 | {
92 | template = template.split("{"+value+"}").join(vars[value]);
93 | }
94 | return template;
95 | }
96 |
97 | var output1 = unique(arr1).join("\n");
98 | output1 = output1.substr(2, output1.length); // remove first 2 tabs for nice copy / paste
99 |
100 | fl.clipCopyString(output2);
101 | var output2 = unique(arr2).join("\n");
102 |
103 | fl.trace("********* Part 1 *********\n\n" + output1 + "\n\n********* Part 2 *********\n\n" + output2);
104 |
105 | function unique(arr)
106 | {
107 | var a = [];
108 | var l = arr.length;
109 | for(var i = 0; i < l; i++)
110 | {
111 | for(var j = i + 1; j < l; j++)
112 | {
113 | if (arr[i] === arr[j]) j = ++i;
114 | }
115 | a.push(arr[i]);
116 | }
117 | return a;
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/commands/[mm] Log instance names.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Scans the current timeline and outputs variable definitions for instance variables to the output window.
3 | *
4 | * Original by http://code.google.com/p/fueljsfl
5 | * @author: Mediamonks - http://www.mediamonks.com
6 | * @author: Mark Knol - http://blog.stroep.nl
7 | */
8 |
9 | fl.outputPanel.clear();
10 |
11 | var items;
12 | var doc = fl.getDocumentDOM();
13 |
14 | var TEMPLATE1 = "\t\tpublic var {variableName}:{className};";
15 |
16 | if (!doc)
17 | {
18 | alert("Please open or create a flashfile.");
19 | }
20 | else
21 | {
22 | LogInstanceNames();
23 | }
24 |
25 | function LogInstanceNames()
26 | {
27 | var timeline = doc.getTimeline();
28 | var layer, frame, elem, cls;
29 | var arr1 = [];
30 | var arr2 = [];
31 | var vars;
32 |
33 | // go through all frames in all layers and search for instance variables.
34 | for (var i = 0, leni = timeline.layers.length; i < leni; i++)
35 | {
36 | layer = timeline.layers[i];
37 |
38 | if (layer.layerType === "guide" || layer.layerType === "guided" || layer.layerType === "folder") continue;
39 |
40 | for (var j = 0, lenj = layer.frames.length; j < lenj; j++)
41 | {
42 | frame = layer.frames[j];
43 | if (j === frame.startFrame) // keyframes only
44 | {
45 | for (var k = 0, lenk = frame.elements.length; k < lenk; k++)
46 | {
47 | elem = frame.elements[k];
48 |
49 | if (elem.elementType == "text" && elem.name)
50 | {
51 | vars = {variableName:elem.name, className:"TextField"};
52 | arr1.push(replaceVars(TEMPLATE1, vars));
53 | continue;
54 | }
55 |
56 | if (!elem.libraryItem) continue;
57 |
58 | if (elem.libraryItem.linkageClassName || elem.libraryItem.linkageBaseClass)
59 | {
60 | if (elem.libraryItem.linkageBaseClass && elem.name)
61 | {
62 | cls = elem.libraryItem.linkageBaseClass.split(".").pop();
63 | vars = {variableName:elem.name, className:cls};
64 | arr1.push(replaceVars(TEMPLATE1, vars));
65 | }
66 | else if (elem.libraryItem.linkageClassName && elem.name)
67 | {
68 | cls = elem.libraryItem.linkageClassName.split(".").pop();
69 | vars = {variableName:elem.name, className:cls};
70 | arr1.push(replaceVars(TEMPLATE1, vars));
71 | }
72 | }
73 | else if (elem.name)
74 | {
75 | vars = {variableName:elem.name, className:"MovieClip"};
76 | arr1.push(replaceVars(TEMPLATE1, vars));
77 | }
78 | }
79 | }
80 | }
81 | }
82 |
83 | function replaceVars(template, vars)
84 | {
85 | for (var value in vars)
86 | {
87 | template = template.split("{"+value+"}").join(vars[value]);
88 | }
89 | return template;
90 | }
91 |
92 | var output1 = unique(arr1).join("\n");
93 | output1 = output1.substr(2, output1.length); // remove first 2 tabs for nice copy / paste
94 |
95 | fl.trace(output1);
96 |
97 | function unique(arr)
98 | {
99 | var a = [];
100 | var l = arr.length;
101 | for(var i = 0; i < l; i++)
102 | {
103 | for(var j = i + 1; j < l; j++)
104 | {
105 | if (arr[i] === arr[j]) j = ++i;
106 | }
107 | a.push(arr[i]);
108 | }
109 | return a;
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/commands/[mm] Multiple library rename.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Renames selected library items
3 | * @version 1
4 | * @author: Mediamonks - http://www.mediamonks.com
5 | * @author: Mark Knol - http://blog.stroep.nl
6 | */
7 |
8 |
9 | fl.outputPanel.clear();
10 |
11 | var items;
12 | var doc = fl.getDocumentDOM();
13 | var PREFIX = "\t\tpublic var ";
14 |
15 | if (!doc)
16 | {
17 | alert("Please open or create a flashfile.");
18 | }
19 | else
20 | {
21 | Rename();
22 | }
23 |
24 | function Rename()
25 | {
26 | var items = fl.getDocumentDOM().library.getSelectedItems();
27 | if (!items.length){
28 | alert('Select multiple items in your librarys')
29 | return;
30 | }
31 |
32 |
33 | var newName = prompt('New name:','');
34 | for(var i = 0; i distributeToLayers
43 | /*if (selectedInstance.layer.frames[doc.getTimeline().currentFrame].elements.length > 1)
44 | {
45 | fl.getDocumentDOM().distributeToLayers();
46 | }*/
47 | }
48 | else
49 | {
50 | return;
51 | }
52 | }
53 |
54 | selectedInstance = doc.selection[0];
55 | var base;
56 |
57 | if (!selectedInstance.libraryItem || selectedInstance.instanceType == "bitmap")
58 | {
59 | if (confirm("Warning: Your selection is not a library item.\nDo you want to convert your selection to a new library item?"))
60 | {
61 | var newName;
62 | if (doc.getTimeline().name == "Scene 1") newName = DEFAULT_CLASS_NAME;
63 | else newName = doc.getTimeline().name + DEFAULT_CLASS_NAME;
64 |
65 | // smart name
66 | if (selectedInstance.instanceType == "bitmap") newName = upperCaseFirstLetter(selectedInstance.libraryItem.name.split(".").shift()) + "Image";
67 | if (selectedInstance instanceof Text)
68 | {
69 | if (doc.getTimeline().name == "Scene 1") newName = "MyLabel";
70 | else newName = doc.getTimeline().name + "Label";
71 | }
72 | convertToSymbol(newName);
73 | selectedInstance.libraryItem.linkageExportForAS = true;
74 | selectedInstance.libraryItem.linkageClassName = getClassPackageName(selectedInstance.libraryItem) + "." + newName;
75 | selectedInstance.libraryItem.linkageBaseClass = "flash.display.MovieClip";
76 |
77 | // when multiple items on current frame > distributeToLayers
78 | if (selectedInstance.layer.frames[doc.getTimeline().currentFrame].elements.length > 1)
79 | {
80 | fl.getDocumentDOM().distributeToLayers();
81 | }
82 | }
83 | else
84 | {
85 | return;
86 | }
87 | }
88 |
89 | var selectedInstanceLibraryItem = selectedInstance.libraryItem;
90 |
91 | var CLASS_LIST = [];
92 |
93 | CLASS_LIST.push(
94 | 'flash.display.MovieClip',
95 | 'flash.display.Sprite',
96 | 'temple.core.display.CoreMovieClip',
97 | 'temple.core.display.CoreSprite',
98 | 'temple.ui.animation.ContinualMovieClip',
99 | 'temple.ui.animation.FrameStableMovieClip',
100 | 'temple.ui.animation.SelfRemovieClip',
101 | 'temple.multilanguage.elements.MultiLanguageMovieClip',
102 | 'temple.ui.buttons.MultiStateButton',
103 | 'temple.ui.buttons.MultiStateElement',
104 | 'temple.ui.buttons.BaseButton',
105 | 'temple.ui.buttons.LabelButton',
106 | 'temple.ui.buttons.AdvancedButton',
107 | 'temple.ui.buttons.SwitchButton',
108 | 'temple.ui.buttons.TweenButton',
109 | 'temple.ui.buttons.URLButton',
110 | 'temple.ui.buttons.LiquidButton',
111 | 'temple.ui.buttons.LiquidLabelButton',
112 | 'temple.ui.layout.liquid.LiquidContainer',
113 | 'temple.ui.layout.liquid.LiquidMovieClip',
114 | 'temple.ui.layout.liquid.LiquidSprite',
115 | 'temple.ui.ImageLoader',
116 | 'temple.multilanguage.ui.MultiLanguageLabel',
117 | 'temple.ui.label.Label',
118 | 'temple.ui.label.LiquidLabel',
119 | 'temple.ui.tooltip.ToolTip',
120 | 'temple.ui.pagination.PaginatorComponent',
121 | 'temple.ui.mouse.MouseCursor',
122 | 'temple.ui.form.components.AutoCompleteInputField',
123 | 'temple.ui.form.components.CheckBox',
124 | 'temple.ui.form.components.ComboBox',
125 | 'temple.ui.form.components.DateInputField',
126 | 'temple.ui.form.components.DateSelector',
127 | 'temple.ui.form.components.InputField',
128 | 'temple.ui.form.components.List',
129 | 'temple.ui.form.components.ListRow',
130 | 'temple.ui.form.components.SubmitButton',
131 | 'temple.ui.form.components.ResetButton',
132 | 'temple.ui.form.components.RadioButton',
133 | 'temple.ui.accordion.Accordion',
134 | 'temple.ui.accordion.AccordionItem',
135 | 'temple.ui.accordion.AccordionHeader',
136 | 'temple.ui.scroll.ScrollBar',
137 | 'temple.ui.scroll.ScrollComponent',
138 | 'temple.ui.scroll.ScrollPane',
139 | 'temple.ui.slider.SliderComponent',
140 | 'temple.ui.slider.StepSliderComponent',
141 | 'temple.ui.states.BaseState',
142 | 'temple.ui.states.BaseFadeState',
143 | 'temple.ui.states.BaseTimelineState',
144 | 'temple.ui.states.disabled.DisabledState',
145 | 'temple.ui.states.disabled.DisabledTimelineState',
146 | 'temple.ui.states.disabled.DisabledFadeState',
147 | 'temple.ui.states.down.DownState',
148 | 'temple.ui.states.down.DownTimelineState',
149 | 'temple.ui.states.down.DownFadeState',
150 | 'temple.ui.states.error.ErrorState',
151 | 'temple.ui.states.error.ErrorTimelineState',
152 | 'temple.ui.states.error.ErrorFadeState',
153 | 'temple.ui.states.focus.FocusState',
154 | 'temple.ui.states.focus.FocusTimelineState',
155 | 'temple.ui.states.focus.FocusFadeState',
156 | 'temple.ui.states.open.OpenState',
157 | 'temple.ui.states.open.OpenTimelineState',
158 | 'temple.ui.states.open.OpenFadeState',
159 | 'temple.ui.states.over.OverState',
160 | 'temple.ui.states.over.OverTimelineState',
161 | 'temple.ui.states.over.OverFadeState',
162 | 'temple.ui.states.select.SelectState',
163 | 'temple.ui.states.select.SelectTimelineState',
164 | 'temple.ui.states.select.SelectFadeState',
165 | 'temple.ui.states.up.UpState',
166 | 'temple.ui.states.up.UpTimelineState',
167 | 'temple.ui.states.up.UpFadeState'
168 | );
169 |
170 | var foundInDoc = 0;
171 | for(var i = 0, leni = doc.library.items.length; i < leni; i++)
172 | {
173 | var item = doc.library.items[i];
174 | if (item.linkageExportForAS && CLASS_LIST.indexOf(item.linkageBaseClass) == -1 && item.linkageBaseClass != "flash.text.Font") {
175 | CLASS_LIST.unshift(item.linkageBaseClass);
176 | foundInDoc++;
177 | }
178 | }
179 |
180 | if (selectedInstanceLibraryItem.linkageExportForAS)
181 | {
182 | CLASS_LIST.unshift(selectedInstanceLibraryItem.linkageBaseClass); // put current active class on top of list
183 | }
184 | else
185 | {
186 | CLASS_LIST.unshift("flash.display.MovieClip");
187 | }
188 |
189 | var steps = {};
190 | steps.step1 = {
191 | question: 'Rename library symbol name?',
192 | label: 'Type new symbol name:',
193 | input: selectedInstanceLibraryItem.name.split('/').pop()
194 | }
195 |
196 | if(!selectedInstanceLibraryItem.linkageImportForRS)
197 | {
198 | steps.step2 = {
199 | question: 'The library symbol ' + (selectedInstanceLibraryItem.linkageExportForAS ? 'already has a base class, change it?' : 'has no Base Class, add it?'),
200 | label: selectedInstanceLibraryItem.linkageExportForAS ? 'Enter new base class:' : 'Enter a base class:',
201 | input: CLASS_LIST
202 | }
203 | }
204 |
205 | var dialogXML = getQuestionXML(steps);
206 |
207 | if (selectedInstanceLibraryItem.linkageImportForRS)
208 | {
209 | dialogXML += '' + SEPARATOR_XML;
210 | }
211 | else
212 | {
213 | dialogXML += '';
214 | dialogXML += '';
215 | dialogXML += '';
216 | dialogXML += ''+ SEPARATOR_XML;
217 | }
218 | dialogXML += ''
219 | var settingsData = createDialogXML(dialogXML, 'Step 1 / 2 : Update the library item ' + selectedInstanceLibraryItem.name + '.');
220 |
221 | if (settingsData.dismiss == 'accept')
222 | {
223 | // store settings locally
224 | if (settingsData.step1) localStorage.saveProperty("step1_checked", settingsData.step1);
225 | if (settingsData.step2) localStorage.saveProperty("step2_checked", settingsData.step2);
226 | if (settingsData.renameInstance) localStorage.saveProperty("renameInstance_checked", settingsData.renameInstance);
227 |
228 | if (settingsData.step1 == 'true')
229 | {
230 | selectedInstanceLibraryItem.name = settingsData.step1_input;
231 | if (selectedInstanceLibraryItem.linkageExportForAS) selectedInstanceLibraryItem.linkageClassName = getClassPackageName(selectedInstanceLibraryItem) + '.' + getClassName(selectedInstanceLibraryItem);
232 | }
233 | if (settingsData.step2 && settingsData.step2 == 'true')
234 | {
235 | if (!selectedInstanceLibraryItem.linkageExportForAS)
236 | {
237 | selectedInstanceLibraryItem.linkageExportForAS = true;
238 | selectedInstanceLibraryItem.linkageClassName = getClassPackageName(selectedInstanceLibraryItem) + '.' + getClassName(selectedInstanceLibraryItem);
239 | }
240 | selectedInstanceLibraryItem.linkageBaseClass = settingsData.step2_input;
241 | selectedInstanceLibraryItem.linkageExportInFirstFrame = (settingsData.exportFrame1 == 'true');
242 | selectedInstanceLibraryItem.linkageExportForRS = (settingsData.runtimeSharedAsset == 'true');
243 | if (selectedInstanceLibraryItem.linkageExportForRS)
244 | {
245 | selectedInstanceLibraryItem.linkageExportInFirstFrame = true;
246 | if (!selectedInstanceLibraryItem.linkageURL)selectedInstanceLibraryItem.linkageURL = doc.name.split(".fla").shift() + ".swf"
247 | }
248 | }
249 | if (settingsData.renameInstance == 'true')
250 | {
251 | settingsData = createDialogXML(
252 | getQuestionXML({step3:{
253 | question: '',
254 | label: 'Enter the new instance name:',
255 | input: 'mc' + upperCaseFirstLetter(selectedInstanceLibraryItem.name.split('/').pop())
256 | }})
257 | , 'Step 2 / 2 : ' + (selectedInstance.name ? 'Change the name of the selected instance ' + selectedInstance.name + ' on the timeline.' : 'The selected instance has no instance name, add it?'));
258 |
259 | if (settingsData.dismiss == 'accept')
260 | {
261 | if (settingsData.step3_input) renameAcrossLayer(settingsData.step3_input, doc);
262 | }
263 | }
264 | }
265 |
266 | // dialog functions
267 |
268 | function getQuestionXML(UIsettings)
269 | {
270 | var retval = '';
271 |
272 | for (var UIsetting in UIsettings)
273 | {
274 | var dialogElementXML = "";
275 | if (UIsettings[UIsetting].question) dialogElementXML += ''
276 |
277 | dialogElementXML += ''
278 | if(typeof(UIsettings[UIsetting].input) == "string" )
279 | {
280 | dialogElementXML += ''
281 | }
282 | else
283 | {
284 | dialogElementXML += ''
285 | for(var i =0;i'
286 | dialogElementXML += ''
287 | }
288 | dialogElementXML += SEPARATOR_XML;
289 | //dialogElementXML += ''
290 |
291 | var variables = UIsettings[UIsetting];
292 | variables.id = UIsetting;
293 | variables.checked = localStorage.getProperty(UIsetting + "_checked") || true;
294 | for(var variable in variables)
295 | {
296 | dialogElementXML = dialogElementXML.split('{' + variable + '}').join(variables[variable]);
297 | }
298 | retval += dialogElementXML;
299 | }
300 |
301 | return retval;
302 | }
303 |
304 | function createDialogXML(xmlString, description)
305 | {
306 | var dialogXML = '';
311 |
312 | var localConfigURI = fl.configURI;
313 | // Verify that the provided path ends with ‘/’
314 | if (localConfigURI.charAt(localConfigURI.length – 1) != "/") localConfigURI = localConfigURI + "/";
315 |
316 | var path = localConfigURI + "Commands/.dialog-" + parseInt(Math.random() * 1000) + ".xml"
317 | FLfile.write(path, xmlString);
318 | var xmlPanelOutput = fl.getDocumentDOM().xmlPanel(path);
319 | FLfile.remove(path);
320 | return xmlPanelOutput;
321 | }
322 |
323 |
324 |
325 |
326 | // other functions
327 |
328 | function convertToSymbol(newName)
329 | {
330 | if (!fl.getDocumentDOM().library.itemExists(newName))
331 | {
332 | fl.getDocumentDOM().convertToSymbol("movie clip", newName, "top left");
333 | selectedInstance = doc.selection[0];
334 | return;
335 | }
336 |
337 | var count = 1; // start count
338 |
339 | while (count < 1000)
340 | {
341 | if (!fl.getDocumentDOM().library.itemExists(newName + count))
342 | {
343 | fl.getDocumentDOM().convertToSymbol("movie clip", newName + count, "top left");
344 | break;
345 | }
346 | count ++;
347 | }
348 | // reset selection
349 | selectedInstance = doc.selection[0];
350 | }
351 |
352 | function unique(arr)
353 | {
354 | var a = [];
355 | var l = arr.length;
356 | for(var i = 0; i < l; i++)
357 | {
358 | for(var j = i + 1; j< l; j++)
359 | {
360 | if (arr[i] === arr[j]) j = ++i;
361 | }
362 | a.push(arr[i]);
363 | }
364 | return a;
365 | }
366 |
367 | function LocalStorage(name)
368 | {
369 | this.url = fl.configURI + "/Commands/" + name + ".localsettings.xml";
370 | this.saveProperty = function(name, value)
371 | {
372 | var file = this.getSettingsFile();
373 | if (file)
374 | {
375 | var currentValue = this.getProperty(name, true);
376 | if (currentValue)
377 | {
378 | file = file.split("<"+name+">" + currentValue + "<").join("<"+name+">" + encode(value) + "<");
379 | }
380 | else
381 | {
382 | file = file.split("").shift() + "\t<"+name+">" + encode(value) + ""+name+">\n" + file.split("").pop();
383 | }
384 | }
385 | else
386 | {
387 | file = "\n\n\n\t<"+name+">" + encode(value) + ""+name+">\n"
388 | }
389 | FLfile.write(this.url, file);
390 | }
391 | this.getProperty = function(name, undecoded)
392 | {
393 | var file = this.getSettingsFile();
394 | if (file.indexOf("<"+name+">") != -1)
395 | {
396 | var value = file.split("<"+name+">").pop().split(""+name+">").shift();
397 | return !undecoded ? decode(value) : value;
398 | }
399 | return null;
400 | }
401 | this.getSettingsFile = function()
402 | {
403 | if (FLfile.exists(this.url))
404 | {
405 | return FLfile.read(this.url);
406 | }
407 | else
408 | {
409 | FLfile.write(this.url, "");
410 | return FLfile.read(this.url);
411 | }
412 | }
413 | function encode(value)
414 | {
415 | return value
416 | .split("<").join("<")
417 | .split(">").join(">")
418 | .split("&").join("&")
419 | .split("'").join("'")
420 | .split('"').join(""");
421 | }
422 | function decode(value)
423 | {
424 | return value
425 | .split("<").join("<")
426 | .split(">").join(">")
427 | .split("&").join("&")
428 | .split("'").join("'")
429 | .split(""").join('"');
430 | }
431 | }
432 |
433 | function upperCaseFirstLetter(value)
434 | {
435 | return value.substring(0, 1).toUpperCase() + value.substr(1, value.length - 1);
436 | }
437 |
438 | function getClassPackageName(item)
439 | {
440 | var retval = doc.name.toLowerCase().split('.fla')[0].split('.xfl')[0];
441 | if (retval) retval = retval.split('..').join('.').split(' ').join('').split('-').join('_').toLowerCase();
442 | return retval;
443 | }
444 |
445 | function getClassName(item)
446 | {
447 | var retval = item.name.substr(item.name.lastIndexOf('/') + 1);
448 | retval = retval.substr(0, 1).toUpperCase() + retval.substr(1);
449 | retval = retval.split('.').join('').split(' ').join('');
450 | return retval;
451 | }
452 |
453 | function renameAcrossLayer(instancename, doc)
454 | {
455 | var timeline = doc.getTimeline();
456 | var selectedFrame = timeline.getSelectedFrames();
457 | var layer = timeline.layers[timeline.currentLayer];
458 | layer.name = instancename;
459 | var framesList = layer.frames;
460 |
461 | var layerList = [];
462 | for (var i = 0, total = timeline.layers.length; i < total; i++)
463 | {
464 | layerList.push(timeline.layers[i].locked);
465 | }
466 |
467 | timeline.setLayerProperty("locked", true, "others");
468 | timeline.setLayerProperty("locked", false, "selected");
469 |
470 | for (var i = 0; i < framesList.length; i++)
471 | {
472 | var frameListItem = framesList[i];
473 | var frameListItemElements = frameListItem.elements;
474 | if (frameListItemElements.length > 1)
475 | {
476 | alert("Renaming instance names only works with layers containing one instance across frames. There is more than one item on frame " + (i + 1) + ".\n\nUse 'Distribute to layers' and try again.");
477 | //fl.getDocumentDOM().distributeToLayers();
478 | break;
479 | }
480 | else
481 | {
482 | if (frameListItemElements.length > 0)
483 | {
484 | var frameListItemElement = frameListItemElements[0];
485 | var symbolname = frameListItemElement.libraryItem.name;
486 |
487 | doc.selectNone();
488 |
489 | if (selectedInstanceLibraryItem.name == symbolname && frameListItem.startFrame == i)
490 | {
491 | timeline.setSelectedFrames(i, i + 1);
492 | doc.selectAll();
493 | doc.selection[0].name = instancename;
494 | }
495 | }
496 | }
497 | }
498 |
499 | for (var i = 0, total = layerList.length; i < total; i++)
500 | {
501 | timeline.setSelectedLayers(i, i);
502 | timeline.setLayerProperty("locked", layerList[i], "selected");
503 | }
504 |
505 | timeline.setSelectedFrames(selectedFrame, selectedFrame + 1);
506 | }
507 |
508 |
509 | };
510 |
--------------------------------------------------------------------------------
/commands/[mm] Organize layers.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Renames layers according first item in layer. With coding standards warnings. Folders are skipped by default.
3 | * @version 1.5
4 | * @author: Mediamonks - http://www.mediamonks.com
5 | * @author: Mark Knol - http://blog.stroep.nl
6 | */
7 |
8 | fl.outputPanel.clear();
9 | var doc = fl.getDocumentDOM();
10 | autoNameLayers(true);
11 |
12 | function autoNameLayers(showWarnings)
13 | {
14 | var timeline = doc.getTimeline();
15 |
16 | for (var i = timeline.layers.length - 1; i >= 0; i--)
17 | {
18 | var layer = timeline.layers[i];
19 |
20 | if (layer.layerType != "guide" && layer.layerType != "mask" && layer.layerType != "folder")
21 | {
22 | var frameNumber = 0;
23 | var element;
24 |
25 | var layerHasCode = false;
26 | var layerHasLabel = false;
27 | var layerHasComment = false;
28 | var layerHasAnchor = false;
29 | var layerHasSound = false;
30 |
31 | for (var j = 0, totalFrames = layer.frames.length; j < totalFrames; j++)
32 | {
33 | var frame = layer.frames[j];
34 | if (j === frame.startFrame) // keyframes only
35 | {
36 | element = frame.elements[0]; // first element on frame1
37 |
38 | if (frame.soundLibraryItem) layerHasSound = true;
39 | if (frame.labelType != "none")
40 | {
41 | if (frame.labelType == "name") layerHasLabel = true
42 | if (frame.labelType == "comment") layerHasComment = true;
43 | if (frame.labelType == "anchor") layerHasAnchor = true;
44 | }
45 | if (frame.actionScript && frame.actionScript.length > 0)
46 | {
47 | layerHasCode = true;
48 | }
49 |
50 | if (element)
51 | {
52 | if(element.name)
53 | {
54 | layer.name = element.name;
55 |
56 | if (showWarnings)
57 | {
58 | if (element.elementType == "instance" && element.name.substring(0, 2) != 'mc' )
59 | {
60 | fl.trace('Warning: instance name of "' + element.name + '" isn\'t named right; should start with "mc".');
61 | }
62 | else if(element.elementType == "text" && element.name.substring(0, 3) != 'txt')
63 | {
64 | fl.trace('Warning: instance name of "' + element.name + '" isn\'t named right; should start with "txt".');
65 | }
66 | }
67 | }
68 | else if (element.libraryItem)
69 | {
70 | layer.name = element.libraryItem.name.split("/").pop().split(".").shift();
71 | }
72 | else if (element.elementType == "text")
73 | {
74 | // empty textfields
75 | layer.name = "textfield";
76 |
77 | // textfields with some text
78 | var charsToShow = 17;
79 | if (element.getTextString()) layer.name = "textfield (" + (element.getTextString().length > charsToShow ? (element.getTextString(0, charsToShow-2) + "..") : element.getTextString()) + ")";
80 | }
81 | else if (element.elementType == "shapeObj")
82 | {
83 | // You'r able to give it your own name
84 | layer.name = (layer.name.indexOf("Layer ") > -1) ? frame.elements.length > 1 ? "objects" : "object" : layer.name;
85 | }
86 | else if (element.elementType == "shape")
87 | {
88 | // You'r able to give it your own name
89 | layer.name = (layer.name.indexOf("Layer ") > -1) ? frame.elements.length > 1 ? "shapes" : "shape" : layer.name;
90 | }
91 | else
92 | {
93 | // dont rename the rest
94 | }
95 | break;
96 | }
97 | }
98 | }
99 |
100 | if (!element && !layerHasCode && !layerHasLabel && !layerHasComment && !layerHasAnchor && !layerHasSound)
101 | {
102 | // remove empty layers
103 | timeline.deleteLayer(i);
104 | }
105 | else
106 | {
107 | // layer names if contains labels or actions
108 | var newLayerName = "";
109 | var isLabelLayer = false;
110 |
111 | if (layerHasLabel) {newLayerName += "/labels"; isLabelLayer = true};
112 | if (layerHasComment) {newLayerName += "/comments"; isLabelLayer = true};
113 | if (layerHasAnchor) {newLayerName += "/anchors"; isLabelLayer = true};
114 | if (layerHasCode) {newLayerName += "/actions"; isLabelLayer = true};
115 | if (layerHasSound) {newLayerName += "/sounds"; isLabelLayer = true};
116 |
117 | if (isLabelLayer)
118 | {
119 | layer.name = newLayerName.substr(1); // remove first slash
120 | }
121 | }
122 |
123 | }
124 | if (layer.layerType == "mask") layer.name = "mask";
125 | else if (layer.layerType == "guide" && layer.name.indexOf("Layer_") != -1) layer.name = "guide";
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/commands/[mm] Organize library.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Organizes bitmaps, videos and sounds in right folders
3 | * @version 1.0
4 | * @author: Mediamonks - http://www.mediamonks.com
5 | * @author: Mark Knol - http://blog.stroep.nl
6 | */
7 |
8 | var doc = fl.getDocumentDOM();
9 |
10 | if (!doc)
11 | {
12 | alert("Please open or create a flashfile.");
13 | }
14 | else
15 | {
16 | OrganizeLibrary();
17 | }
18 |
19 | function OrganizeLibrary()
20 | {
21 | var library = doc.library;
22 | var items = library.items;
23 |
24 | organizeInRootFolder("bitmap", "_images");
25 | organizeInRootFolder("video", "_videos");
26 | organizeInRootFolder("sound", "_sounds");
27 |
28 | removeForbiddenFolders("_images", ["images","bitmap","_bitmap","image","_bitmaps","pictures","_pictures","_picture","_image"]);
29 | removeForbiddenFolders("_videos", ["video","_video","_movies","_movie","_flv","videos"]);
30 | removeForbiddenFolders("_sounds", ["sounds", "_sound", "_wav", "sound"]);
31 |
32 | function organizeInRootFolder(itemType, destinationFolder)
33 | {
34 | var i = items.length;
35 | while (i--)
36 | {
37 | var item = items[i];
38 | if (item.itemType === itemType && item.name.indexOf("/") === -1)
39 | {
40 | library.newFolder(destinationFolder);
41 | library.moveToFolder(destinationFolder, item.name, true);
42 | }
43 | }
44 | }
45 |
46 | function removeForbiddenFolders(goodFolderName, forbiddenFolderNames)
47 | {
48 | var k = forbiddenFolderNames.length;
49 | while(k--)
50 | {
51 | var forbiddenFolderName = forbiddenFolderNames[k]
52 | i = items.length;
53 | while (i--)
54 | {
55 | var item = items[i];
56 | if (item.itemType === "folder" && item.name === forbiddenFolderName)
57 | {
58 | var j = items.length;
59 | while (j--)
60 | {
61 | var itemj = items[j];
62 | if (itemj.itemType !== "folder" && itemj.name.indexOf(forbiddenFolderName) === 0)
63 | {
64 | library.newFolder(goodFolderName);
65 | library.moveToFolder(goodFolderName, itemj.name, true);
66 | }
67 | }
68 | library.deleteItem(item.name);
69 | }
70 |
71 | }
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/commands/[mm] Random instance swapper.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Random item swapper.
3 | * Howto: Select multiple library items, select multiple items on stage. Randomize.
4 | * @version 1
5 | * @author: Mediamonks - http://www.mediamonks.com
6 | * @author: Mark Knol - http://blog.stroep.nl
7 | */
8 |
9 | fl.outputPanel.clear();
10 |
11 | var doc = fl.getDocumentDOM();
12 |
13 | if (!doc)
14 | {
15 | alert("Please open or create a flashfile.");
16 | }
17 | else
18 | {
19 | RandomSwap();
20 | }
21 |
22 | function RandomSwap()
23 | {
24 | var libraryItems = fl.getDocumentDOM().library.getSelectedItems();
25 | var selectedItems = doc.selection;
26 |
27 | if (!libraryItems.length)
28 | {
29 | alert('Select at least 1 item in your library')
30 | return;
31 | }
32 |
33 | if (!selectedItems || !selectedItems.length)
34 | {
35 | alert('Select at least 1 item on stage')
36 | return;
37 | }
38 |
39 | for each(var selectedItem in selectedItems)
40 | {
41 | selectedItem.libraryItem = libraryItems[Math.floor(Math.random() * libraryItems.length)]
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/commands/[mm] Random rotation.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Rotates instances
3 | * @version 1
4 | * @author: Mediamonks - http://www.mediamonks.com
5 | * @author: Mark Knol - http://blog.stroep.nl
6 | */
7 |
8 | fl.outputPanel.clear();
9 |
10 | var doc = fl.getDocumentDOM();
11 |
12 | if (!doc)
13 | {
14 | alert("Please open or create a flashfile.");
15 | }
16 | else
17 | {
18 | RandomRotation();
19 | }
20 |
21 | function RandomRotation()
22 | {
23 | var selectedItems = doc.selection;
24 |
25 | if (!selectedItems || !selectedItems.length)
26 | {
27 | alert('Select at least 1 item on stage')
28 | return;
29 | }
30 |
31 | var rotations = [0,90,180,270];
32 |
33 | for each(var selectedItem in selectedItems)
34 | {
35 | selectedItem.rotation = rotations[Math.floor(Math.random() * rotations.length)];
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/commands/[mm] Rename across layer.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Renames instance names, layers, library items with easy 3-step wizard.
3 | * @version 1.1
4 | * @author: Mark Knol - http://blog.stroep.nl
5 | */
6 |
7 | var doc = fl.getDocumentDOM();
8 | var selectedInstance;
9 |
10 | if (!doc)
11 | {
12 | alert("Please open or create a flashfile.");
13 | }
14 | else
15 | {
16 | NameItRight();
17 | }
18 |
19 | function NameItRight()
20 | {
21 | if (!doc.selection || !doc.selection[0])
22 | {
23 | alert("You need to select one instance on stage to do the magic.");
24 | return;
25 | }
26 | else if (doc.selection.length != 1)
27 | {
28 | alert("You may have no more than one stage element selected. You need to select one instance on stage to do the magic.");
29 | return;
30 | }
31 |
32 | selectedInstance = doc.selection[0];
33 | var base;
34 |
35 | if (!selectedInstance.libraryItem)
36 | {
37 | alert("Your selection is not a library item; First convert it to a symbol");
38 | return;
39 | }
40 |
41 | var selectedInstanceLibraryItem = selectedInstance.libraryItem;
42 |
43 | var newInstanceName = prompt('Enter new instance name.', 'mc' + upperCaseFirstLetter(selectedInstanceLibraryItem.name.split("/").pop()));
44 | if (newInstanceName) renameAcrossLayer(newInstanceName, doc);
45 |
46 | function upperCaseFirstLetter(value)
47 | {
48 | return value.substring(0, 1).toUpperCase() + value.substr(1, selectedInstanceLibraryItem.name.length - 1);
49 | }
50 |
51 | function renameAcrossLayer(instancename, doc)
52 | {
53 | var timeline = doc.getTimeline();
54 | var selectedFrame = timeline.getSelectedFrames();
55 | var layer = timeline.layers[timeline.currentLayer];
56 | layer.name = instancename;
57 | var framesList = layer.frames;
58 |
59 | var layerList = [];
60 | for (var i = 0, total = timeline.layers.length; i < total; i++)
61 | {
62 | layerList.push(timeline.layers[i].locked);
63 | }
64 |
65 | timeline.setLayerProperty("locked", true, "others");
66 | timeline.setLayerProperty("locked", false, "selected");
67 |
68 | for (var i = 0, total = framesList.length; i < total; i++)
69 | {
70 | var frameListItem = framesList[i];
71 | var frameListItemElements = frameListItem.elements;
72 | if (frameListItemElements.length > 1)
73 | {
74 | alert("There is more than one item on frame " + (i + 1) + ".\nRenaming instance names only works with layers containing one instance across frames.");
75 | break;
76 | }
77 | else
78 | {
79 | if (frameListItemElements.length > 0)
80 | {
81 | var frameListItemElement = frameListItemElements[0];
82 | var symbolname = frameListItemElement.libraryItem.name;
83 |
84 | doc.selectNone();
85 |
86 | if (selectedInstanceLibraryItem.name == symbolname && frameListItem.startFrame == i)
87 | {
88 | timeline.setSelectedFrames(i, i + 1);
89 | doc.selectAll();
90 | doc.selection[0].name = instancename;
91 | }
92 | }
93 | }
94 | }
95 |
96 | for (var i = 0, total = layerList.length; i < total; i++)
97 | {
98 | timeline.setSelectedLayers(i, i);
99 | timeline.setLayerProperty("locked", layerList[i], "selected");
100 | }
101 |
102 | timeline.setSelectedFrames(selectedFrame, selectedFrame + 1);
103 | }
104 | };
105 |
--------------------------------------------------------------------------------
/commands/[mm] Rename library items.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Check for empty clips in library
3 |
4 | * @author: Mediamonks - http://www.mediamonks.com
5 | * @author: Mark Knol - http://blog.stroep.nl
6 | */
7 |
8 | fl.outputPanel.clear();
9 |
10 | var doc = fl.getDocumentDOM();
11 |
12 | RenameClipsInLibrary();
13 |
14 | function RenameClipsInLibrary()
15 | {
16 | var fromRename = prompt("Search for");
17 | if (fromRename != null) {
18 | var toRename = prompt("Replace to");
19 | if (toRename != null) {
20 | fl.trace("Replacing clips with '" + fromRename + "' to '" + toRename + "'");
21 | var foundSomething = false;
22 | var libraryItems = fl.getDocumentDOM().library.items;
23 | var completed = [];
24 | for (var i = libraryItems.length - 1; i >= 0; i--) {
25 | var item = libraryItems[i];
26 | if (item.itemType =="movie clip" || item.itemType =="graphic") {
27 | var index = item.name.indexOf(fromRename);
28 | if (index != -1) {
29 | var oldName = item.name;
30 | item.name = item.name.split("/").pop().replace(fromRename, toRename);
31 | item.linkageClassName = item.name.split("/").pop();
32 | fl.trace(oldName + " is renamed to " + toRename);
33 | foundSomething = true;
34 | }
35 | }
36 | }
37 |
38 | if (!foundSomething) fl.trace("No clips have been renamed");
39 | }
40 | }
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/commands/[mm] Selected Library Items to MovieClips.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * @author: Mediamonks - http://www.mediamonks.com
3 | * @author: Mark Knol - http://blog.stroep.nl
4 | */
5 |
6 |
7 | var items;
8 | var doc = fl.getDocumentDOM();
9 |
10 | if (!doc)
11 | {
12 | alert("Please open or create a flashfile.");
13 | }
14 | else
15 | {
16 | ItemsToMovieClips();
17 | }
18 |
19 | function ItemsToMovieClips()
20 | {
21 | var output = "";
22 |
23 | var items = fl.getDocumentDOM().library.getSelectedItems();
24 | var item;
25 |
26 | for (var i = 0, leni = items.length; i < leni; i++)
27 | {
28 | item = items[i];
29 | if (item.itemType == "folder") continue;
30 | item.linkageExportForAS = true;
31 | item.name = item.name.split("/").pop().split("-").join("_").split(" ").join("_");
32 | item.linkageClassName = item.name.split("/").pop();
33 | item.linkageBaseClass = "flash.display.MovieClip";
34 | item.linkageExportInFirstFrame = true;
35 | }
36 |
37 | function getClassPackageName()
38 | {
39 | var retval = doc.name.toLowerCase().split('.fla')[0].split('.xfl')[0];
40 | if (retval) retval = retval.split('..').join('.').split(' ').join('').split('-').join('_').toLowerCase();
41 | return retval;
42 | }
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/commands/[mm] Selected Library Items to Sprites.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @version 1
4 | * @author: Mark Knol - http://blog.stroep.nl
5 | */
6 |
7 |
8 | var items;
9 | var doc = fl.getDocumentDOM();
10 |
11 | if (!doc)
12 | {
13 | alert("Please open or create a flashfile.");
14 | }
15 | else
16 | {
17 | ItemsToSprites();
18 | }
19 |
20 | function ItemsToSprites()
21 | {
22 | var output = "";
23 |
24 | var items = fl.getDocumentDOM().library.getSelectedItems();
25 | var item;
26 |
27 | for (var i = 0, leni = items.length; i < leni; i++)
28 | {
29 | item = items[i];
30 | if (item.itemType == "folder") continue;
31 |
32 | item.linkageExportForAS = true;
33 | item.name = item.name.split("/").pop().split("-").join("_").split(" ").join("_");
34 | item.linkageClassName = item.name.split("/").pop();
35 | item.linkageBaseClass = "flash.display.Sprite";
36 | item.linkageExportInFirstFrame = true;
37 | }
38 |
39 | function getClassPackageName()
40 | {
41 | var retval = doc.name.toLowerCase().split('.fla')[0].split('.xfl')[0];
42 | if (retval) retval = retval.split('..').join('.').split(' ').join('').split('-').join('_').toLowerCase();
43 | return retval;
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/commands/[mm] Selection to MovieClips.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Selection to MovieClips
3 | * @version 1
4 | * @author: Mediamonks - http://www.mediamonks.com
5 | * @author: Mark Knol - http://blog.stroep.nl
6 | */
7 |
8 | fl.outputPanel.clear();
9 |
10 | var doc = fl.getDocumentDOM();
11 |
12 | if (!doc)
13 | {
14 | alert("Please open or create a flashfile.");
15 | }
16 | else
17 | {
18 | SelectionToMovieClips();
19 | }
20 |
21 | function SelectionToMovieClips()
22 | {
23 | var selectedItems = doc.selection;
24 |
25 | if (!selectedItems || !selectedItems.length)
26 | {
27 | alert('Select at least 1 item on stage')
28 | return;
29 | }
30 |
31 | var alignments = ["top left", "top center", "top right", "center left", "center", "center right", "bottom left", "bottom center", "bottom right"];
32 |
33 | //var prefix = prompt('Enter new name (prefix):', '')
34 | var dialogXML = ''
35 | dialogXML += '';
36 | dialogXML += '';
37 |
38 | dialogXML += '';
39 |
40 | dialogXML += ''
41 | for (var i =0;i'
42 | dialogXML += ''
43 |
44 | var dialogData = createDialogXML(dialogXML)
45 |
46 | if (dialogData && dialogData.prefix && dialogData.alignment)
47 | {
48 | var library = fl.getDocumentDOM().library;
49 |
50 | var count = 1;
51 |
52 | for each(var selectedItem in selectedItems)
53 | {
54 | fl.getDocumentDOM().selectNone();
55 |
56 | selectedItem.selected = true;
57 |
58 | var newName = dialogData.prefix + count;
59 |
60 | fl.getDocumentDOM().convertToSymbol("movie clip", newName, dialogData.alignment);
61 |
62 | count ++
63 | selectedItem.selected = false;
64 | }
65 | }
66 |
67 | function createDialogXML(xmlString, description)
68 | {
69 | var dialogXML = '';
74 |
75 | var url = fl.configURI + 'Commands/temp-dialog-' + parseInt(Math.random() * 777 * 777) + '.xml';
76 | FLfile.write(url, dialogXML);
77 |
78 | var panelOutput = fl.getDocumentDOM().xmlPanel(url);
79 |
80 | FLfile.remove(url);
81 |
82 | return panelOutput;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/commands/[mm] Snap Selection to pixel.jsfl:
--------------------------------------------------------------------------------
1 | /**
* Snaps selection to pixel
*
* @author: Mediamonks - http://www.mediamonks.com
* @author: Mark Knol - http://blog.stroep.nl
*/
var doc = fl.getDocumentDOM();
var selectedInstance;
if (!doc)
{
alert("Please open or create a flashfile.");
}
else
{
SnapSelectionToPixel();
}
function SnapSelectionToPixel()
{
if (!doc.selection || !doc.selection[0])
{
}
else
{
for each(var element in doc.selection)
{
snapPixels(element);
}
}
}
function snapPixels( element ) {
var oldx = element.x;
var oldy = element.y;
var newX;
var newY;
// oddly, more reliable than Math.round.
if ( element.x - Math.floor( element.x ) < .5 ) {
newX = Math.floor( element.x );
} else {
newX = Math.ceil( element.x );
}
if ( element.y - Math.floor( element.y ) < .5 ) {
newY = Math.floor( element.y );
} else {
newY = Math.ceil( element.y );
}
// Fix for the weird offset that flash applies to the element
element.x = newX;
element.x = element.x + (newX - element.x) * 2;
element.y = newY;
element.y = element.y + (newY - element.y) * 2;
if ( oldx - element.x != 0 || oldy - element.y != 0 ) {
return 1;
}
return 0;
}
--------------------------------------------------------------------------------
/commands/[mm] Snap to pixel.jsfl:
--------------------------------------------------------------------------------
1 | /*
* Copyright (c) 2007 Squidder.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
var flash_doc = fl.getDocumentDOM();
var flash_lib = flash_doc.library;
var flash_tl = flash_doc.getTimeline();
var elementsModified = 0;
var confirmation = true;
if ( flash_tl.layerCount * flash_tl.frameCount > 100 ) {
confirmation = confirm( "SnapToPixel\n\nBecause of the large number of frames, this process may take some time. Are you sure you want to continue?" );
}
if ( confirmation ) {
for ( var i = 0 ; i < flash_tl.layerCount; i ++ ) {
for ( var j = 0 ; j < flash_tl.layers[ i ].frameCount ; j ++ ) {
var currFrame = flash_tl.layers[ i ].frames[ j ];
if ( j == currFrame.startFrame ) { // Only run on keyframes.
for ( var k = 0 ; k < currFrame.elements.length ; k ++ ) {
elementsModified += snapPixels( currFrame.elements[ k ] );
}
}
}
}
}
/*
if ( elementsModified == 0 ) {
alert( "SnapToPixel\n\nNo instances were modified" );
} else if ( elementsModified == 1 ){
alert( "SnapToPixel\n\n1 instances was modified" );
} else {
alert( "SnapToPixel\n\n" + elementsModified + " instances were modified" );
}
*/
function snapPixels( element ) {
var oldx = element.x;
var oldy = element.y;
var newX;
var newY;
// oddly, more reliable than Math.round.
if ( element.x - Math.floor( element.x ) < .5 ) {
newX = Math.floor( element.x );
} else {
newX = Math.ceil( element.x );
}
if ( element.y - Math.floor( element.y ) < .5 ) {
newY = Math.floor( element.y );
} else {
newY = Math.ceil( element.y );
}
// Fix for the weird offset that flash applies to the element
element.x = newX;
element.x = element.x + (newX - element.x) * 2;
element.y = newY;
element.y = element.y + (newY - element.y) * 2;
if ( oldx - element.x != 0 || oldy - element.y != 0 ) {
return 1;
}
return 0;
}
--------------------------------------------------------------------------------
/commands/[mm] Transform selection manager.jsfl:
--------------------------------------------------------------------------------
1 | /**
2 | * Selection transform manager. Transforms all selected items individually.
3 | * @version 1.1
4 | * @author: Mediamonks - http://www.mediamonks.com
5 | * @author: Mark Knol - http://blog.stroep.nl
6 | */
7 |
8 | fl.outputPanel.clear();
9 |
10 | var doc = fl.getDocumentDOM();
11 |
12 | if (!doc)
13 | {
14 | alert("Please open or create a flashfile.");
15 | }
16 | else
17 | {
18 | TransformSelection();
19 | }
20 |
21 | function TransformSelection()
22 | {
23 | var selectedItems = doc.selection;
24 |
25 | if (!selectedItems || !selectedItems.length)
26 | {
27 | alert('Select at least 1 item on stage')
28 | return;
29 | }
30 |
31 | var properties = ["scaleX","scaleY","skewX","skewY","x","y","width","height","rotation"];
32 | var defaultValue = ["1","1","0","0","0","0","","","0"];
33 |
34 | var dialogXML = '';
35 |
36 | var c = 0;
37 |
38 | for each (var prop in properties)
39 | {
40 | dialogXML += ''
41 |
42 | if (prop!="rotation")
43 | {
44 | if (!defaultValue[c])
45 | {
46 | dialogXML += ''
47 | }
48 | else
49 | {
50 | dialogXML += ''
51 | dialogXML += ''
52 | dialogXML += ''
53 | dialogXML += ''
54 | }
55 | }
56 | else
57 | {
58 | dialogXML += ''
59 | for(var i=0;i<=360;i++) dialogXML += ''
60 | dialogXML += ''
61 | }
62 |
63 | dialogXML += ''
64 | dialogXML += ''
65 |
66 | c++;
67 | }
68 | dialogXML += ''
69 |
70 | var data = createDialogXML(dialogXML);
71 |
72 | for each(var selectedItem in selectedItems)
73 | {
74 | for each(var prop in properties)
75 | {
76 | if (data[prop + "_value"])
77 | {
78 | if (data[prop + "_relative"] == "true")
79 | {
80 | selectedItem[prop] += Number(data[prop + "_value"]);
81 | }
82 | else
83 | {
84 | selectedItem[prop] = Number(data[prop + "_value"]);
85 | }
86 | }
87 | }
88 | }
89 | }
90 |
91 | function createDialogXML(xmlString)
92 | {
93 | var dialogXML = '';
96 |
97 |
98 | var localConfigURI = fl.configURI;
99 | // Verify that the provided path ends with ‘/’
100 | if (localConfigURI.charAt(localConfigURI.length – 1) != "/") localConfigURI = localConfigURI + "/";
101 |
102 | var path = localConfigURI + "Commands/.dialog-" + parseInt(Math.random() * 1000) + ".xml"
103 | FLfile.write(path, xmlString);
104 | var xmlPanelOutput = fl.getDocumentDOM().xmlPanel(path);
105 | FLfile.remove(path);
106 | return xmlPanelOutput;
107 | }
--------------------------------------------------------------------------------
/images/autorenamelayer-explanation.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markknol/flash-jsfl-tools/00d1973028c53c664922aba565ca4259a121d6eb/images/autorenamelayer-explanation.jpg
--------------------------------------------------------------------------------
/images/duplicate-advanced.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markknol/flash-jsfl-tools/00d1973028c53c664922aba565ca4259a121d6eb/images/duplicate-advanced.gif
--------------------------------------------------------------------------------
/images/loginstancenames-explanation.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markknol/flash-jsfl-tools/00d1973028c53c664922aba565ca4259a121d6eb/images/loginstancenames-explanation.jpg
--------------------------------------------------------------------------------
/images/nameitright-explanation.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markknol/flash-jsfl-tools/00d1973028c53c664922aba565ca4259a121d6eb/images/nameitright-explanation.jpg
--------------------------------------------------------------------------------
/images/selectiontransformmanager-explanation.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/markknol/flash-jsfl-tools/00d1973028c53c664922aba565ca4259a121d6eb/images/selectiontransformmanager-explanation.jpg
--------------------------------------------------------------------------------