[mtasc] Developing on OSX with Flash IDE, Textmate and MTASC
Chris Sessions
csessions at gmail.com
Wed Jun 7 22:12:28 CEST 2006
Hi all,
Based on Ben Jackson's article, 'HOWTO: Develop Flash on Mac OSX with
Rake, MTASC, SWFMill and TextMate', here is a solution for developing
on OSX with the Flash IDE, Textmate and MTASC.
First create a new Actionscript command in Textmate's Bundle Editor:
#!/usr/bin/env ruby
#
# Build - recompile an existing swf using MTASC
#
# Created by Chris Sessions on 2006-06-02.
# Copyright (c) 2006. MIT License.
require "open3"
require "yaml"
def mtasc_compile
Dir.chdir(ENV['TM_PROJECT_DIRECTORY'])
yml = YAML.load(File.open('mtasc.yml'))
cmd = "/usr/local/bin/mtasc #{ENV['TM_PROJECT_DIRECTORY']}/#{yml
['app']} -swf #{yml['swf']} -version #{yml['player']} -cp #{yml
['classpaths'].join(' -cp ')}"
puts "<p style=\"color: #666;\">#{cmd}</p>"
stdin, stdout, stderr = Open3.popen3(cmd)
warnings = []
errors = []
while err = stderr.gets
if err[0, 10] == 'Warning : '
warnings.push(err.chomp)
else
m = /(.+):([0-9]+): characters ([0-9]+)/.match(err)
if m != nil
a = "txmt://open?url=file://#{m[1]}&line=#{m[2]}&column=#{m
[3].to_i + 1}"
err = "<a href=\"#{a}\">#{err}</a>"
end
errors.push(err.chomp)
end
end
if !errors.empty?
puts '<h1>Errors:</h1>'
puts "<p>#{errors.uniq.join('</p><p>')}</p>"
end
if !warnings.empty?
puts '<h1>Warnings:</h1>'
puts "<p>#{warnings.uniq.join('</p><p>')}</p>"
end
if errors.empty? && warnings.empty?
puts '<script type="text/javascript">self.close()</script>'
`open #{yml['preview']}`
end
end
if File.exist?("#{ENV['TM_PROJECT_DIRECTORY']}/mtasc.yml")
# compile with MTASC
mtasc_compile
else
# compile with Flash IDE
`echo "flash.getDocumentDOM().testMovie()" > /tmp/test.jsfl; open /
tmp/test.jsfl;`
puts '<script type="text/javascript">self.close()</script>'
end
I called mine "Build in MTASC" and set the key equivalent to CMD-
Enter. I changed the "Test Movie" key equivalent to CMD-SHIFT-Enter
so that I can still call it explicitly.
The Ruby script looks for a yaml file in your project directory (top
level) called 'mtasc.yml', and if it finds it then it attempts to
compile with MTASC. If it's not there the script calls up the Flash
IDE (like Test Movie) to compile instead. Here's a sample mtasc.yml
file:
swf: /www/cke/slayer/htdocs/swfs/promos/burgerslayer.swf
app: Application.as
preview: http://cke/slayer
player: 8
classpaths:
- /www/cke/slayer/_flash
- /www/_libraries_/as2b
- /www/_libraries_/as2b/mtasc/std
Where swf: is the existing swf initially compiled in the Flash IDE,
app: is your main application class, and preview: is a url to preview
the revised swf. I don't use the -out or -main features in MTASC, but
they could easily be plugged in.
You'll get an error if the original swf doesn't exist. If that
happens use CMD-SHIFT-Enter to compile it in the Flash IDE.
Like Ben's example this outputs any compilation errors into an HTML
window with links back to your code in Textmate.
Thanks to everyone for answering my questions while working this out.
I look forward to seeing your improvements to it.
Chris Sessions
csessions at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/mtasc/attachments/20060607/78d96b6f/attachment-0001.htm
More information about the mtasc
mailing list