-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.jsfl
More file actions
121 lines (93 loc) · 2.84 KB
/
Copy pathrender.jsfl
File metadata and controls
121 lines (93 loc) · 2.84 KB
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
118
/* *********************************************************
*
* Copyright (c) 2005, Southpaw Technology
* All Rights Reserved
*
* PROPRIETARY INFORMATION. This software is proprietary to
* Southpaw Technolog, and is not to be reproduced, transmitted,
* or disclosed in any way without written permission.
*
*/
function include (file, base_dir)
{
try {
var contents = FLfile.read("file:///" + base_dir + "/" + file )
eval( contents )
} catch (err) {
fl.trace(err)
}
}
common = new Common()
/* convert all the layers of a shot into guide layers */
function convert_to_guide(doc, prefix)
{
timeline = doc.getTimeline()
// get all of the layers
layers = timeline.layers
for (var i = 0; i < layers.length; i++ )
{
var layer = layers[i]
fl.trace(layer.name)
var reg = "^" + prefix + ":"
if ( ! layer.name.match(reg) && layer.name != prefix)
{
// set to a guide layer
layer.layerType = "guide"
}
}
}
function render_layer(prefix, file_format, render_dir, log_path)
{
// Remove the log file first
var succeed = FLfile.remove("file:///" + log_path)
// if there is no document then just exit
var cur_doc = fl.getDocumentDOM()
if (cur_doc == null)
{
common.exit("false", log_path)
return
}
common.introspect(cur_doc, render_dir + '/introspect.xml')
// if there is no preifx, then render the whole file
if (prefix != null) {
convert_to_guide(cur_doc, prefix)
}
else {
prefix = "render"
}
// create folder for the render path
FLfile.createFolder('file:///' + render_dir)
if (file_format != 'swf')
{
// preprocessing
/* handle this later
fl.runScript( preprocess_path, 'preprocess_layer', layer_name
, cam_layer_name , log_path )
*/
fl.getDocumentDOM().exportPublishProfile('file:///' + render_dir + '/'
+ 'profile.xml')
}
// render swf or png
if (file_format =='swf')
{
fl.getDocumentDOM().exportSWF('file:///' + render_dir + '/'
+ prefix + '.swf', true)
fl.getDocumentDOM().exportPNG('file:///' + render_dir + '/'
+ prefix + '.png' , true, true)
}
else if (file_format =='png')
fl.getDocumentDOM().exportPNG('file:///' + render_dir + '/'
+ prefix + '.' , true, false)
else
alert("Unknown render file format [" + file_format + "]")
// clean up
//cur_doc.close(false)
common.exit("true", log_path)
}
function write_render_log(render_dir, render_log)
{
// create a file to signal render finished
var out_URI = 'file:///' + render_dir + '/' + render_log;
if (!FLfile.write(out_URI, 'Render finished'))
alert("writing render log failed")
}