This repository has been archived by the owner on Jan 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwrap selected as new symbol.jsfl
117 lines (106 loc) · 3.01 KB
/
wrap selected as new symbol.jsfl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* Wraps all selected items in the library in a movie
* clip, with registration point set to 0,0.
*/
ConvertAllToClips = function(){}
var proto = ConvertAllToClips.prototype;
proto.doc = fl.getDocumentDOM();
proto.init = function()
{
if(xmui.dismiss == "accept")
{
this.lib = this.doc.library;
var cItems = this.lib.getSelectedItems();
var cLength = cItems.length;
//add a temporary clip to the library in which conversion takes place:
this.lib.addNewItem("movie clip", "_tmpConversionClip");
this.lib.editItem("_tmpConversionClip");
//put selected library items to stage:
for(var i = 0; i < cLength; i++)
{
//this.lib.selectItem(cItems[i].name);
this.lib.addItemToDocument({x:0, y:0}, cItems[i].name);
}
//select all items:
this.doc.selectNone();
this.doc.selectAll();
this.doc.distributeToLayers();
//delete the first layer, it's empty now:
this.doc.getTimeline().deleteLayer(0);
//get all layers again:
var currentLayers = this.doc.getTimeline().layers;
//first lock all layers:
var i = 0;
for(i in currentLayers)
{
currentLayers[i].locked = true;
}
//create folder:
this.lib.newFolder(xmui.folderName);
//then unlock layer by layer, convert, then lock again:
var j = 0;
var cl = currentLayers.length; // use backwards counting value for layers so item order stays correct.
for(j in currentLayers)
{
cl--;
if(!currentLayers[cl])
{
fl.trace("NOT HERE");
break;
}
currentLayers[cl].locked = false;
this.doc.selectNone();
this.doc.selectAll();
//check if leading zeroes should be used:
if (xmui.leadingZeroes == "true")
{
//check how many zeroes are actually needed:
var tmpLength = currentLayers.length;
if(tmpLength < 100)
{
if(j < 10) var lz = "0";
else if(j >= 10) var lz = "";
}
else if(tmpLength >= 100 && tmpLength < 1000)
{
if (j < 10) var lz = "00";
else if (j >= 10 && j < 100) var lz = "0";
else if (j >= 100) var lz = "";
}
else if (tmpLength >= 1000)
{
if (j < 10) var lz = "000";
else if (j >= 10 && j < 100) var lz = "00";
else if (j >= 100 && j < 1000) var lz = "0";
else if (j >= 1000) var lz = "";
}
}
else
{
var lz = "";
}
//finally convert selected item:
this.doc.convertToSymbol(xmui.itemType, xmui.itemName + lz + j, xmui.regPoint);
this.lib.moveToFolder(xmui.folderName);
this.doc.getTimeline().deleteLayer();
}
//delete the rest:
this.doc.selectNone();
this.doc.selectAll();
if(this.doc.selection.length > 0) this.doc.deleteSelection();
this.doc.exitEditMode();
this.lib.deleteItem("_tmpConversionClip");
}
}
var theDoc = fl.getDocumentDOM();
if (!theDoc) alert("You need to open a Flash file first!");
else
{
if(theDoc.library.getSelectedItems().length <= 1) alert("Please select at least two items in the library!");
else
{
var xmui = theDoc.xmlPanel(fl.configURI + "Commands/xmui/wrap selected as new symbol.xml");
var obj = new ConvertAllToClips();
obj.init();
}
}