Created
January 16, 2009 23:22
-
-
Save osi/48206 to your computer and use it in GitHub Desktop.
"Publish" a folder of FLA files using Flash CS3/4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU | |
require "fileutils" | |
def generate_jsfl(fla, log) | |
return <<EOF | |
var sourceFile = "file://#{Dir.pwd}/#{fla}"; | |
var logFile = "file://#{log}"; | |
var doc = fl.openDocument(sourceFile); | |
fl.outputPanel.clear(); | |
fl.compilerErrors.clear(); | |
fl.getDocumentDOM().publish(); | |
fl.outputPanel.save(logFile, true); | |
fl.compilerErrors.save(logFile, true); | |
fl.getDocumentDOM().close(false); | |
EOF | |
end | |
def publish(fla) | |
puts "Publishing #{fla} ..." | |
log = "/tmp/publish/output" | |
jsfl = generate_jsfl(fla, log) | |
# puts jsfl | |
FileUtils.rm log, :force => true | |
jsfl_script = "/tmp/publish/go.jsfl" | |
File.open(jsfl_script, 'w') { |f| f.write(jsfl)} | |
`open --background #{jsfl_script}` | |
while not File.exist? log | |
sleep 1 | |
end | |
sleep 2 # another 2 for good measure | |
contents = File.new(log).read | |
contents.gsub! "\r", "\n" | |
if contents.length > 3 | |
STDERR.puts "Unable to build #{fla}:\n" | |
STDERR.puts contents | |
exit 2 | |
end | |
end | |
FileUtils.mkdir_p "/tmp/publish" | |
if ARGV.empty? | |
puts "Publishing src/*.fla" | |
Dir.glob("src/*.fla") { |fla| publish fla } | |
else | |
ARGV.each { |fla| publish fla } | |
end | |
puts "Publish complete" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment