Class: Sprout::MTASCTask
- Inherits:
-
ToolTask
- Object
- ToolTask
- Sprout::MTASCTask
- Defined in:
- lib/sprout/tasks/mtasc_task.rb,
lib/sprout/tasks/mtasc_rdoc.rb,
lib/sprout/tasks/mtasc_documentation.rb
Overview
Compile sources using the Motion Twin ActionScript Compiler (MTASC).
Like standard Rake file tasks, the name given to the MTASCTask instance should be the file that the task is epected to create. This value can be overridden in the configuration block by using the -output parameter.
mtasc 'bin/SomeProject.swf' do |t|
t.main = true
t.header = '800:600:24'
t.input = 'src/SomeProject.as'
end
The above MTASCTask can be aliased for easier typing on the command line as follows:
desc "Compile SomeProject.swf"
task :compile => 'bin/SomeProject.swf'
If the MTASCTask has a SWFMillTask as a prerequisite, it will automatically set that task output as the value of the -swf paramter. Additionally, when MTASC pulls in an existing SWF file you no longer need to define the -header parameter as it will use the dimensions and frame rate found in the loaded SWF file. If the -header parameter is set, it will override whatever settings are in the loaded SWF. Following is a short example:
swfmill 'bin/SomeProjectSkin.swf' do |t|
t.input = 'assets/skin'
end
mtasc 'bin/SomeProject.swf' => 'bin/SomeProjectSkin.swf' do |t|
t.main = true
t.input = 'src/SomeProject.as'
end
Any LibraryTask instances that are added as prerequisites to the MTASCTask will be automatically added to the class_path in the order they are declared as prerequisites.
The following example will add the imaginary libraries :somelib, :otherlib and :yourlib to the class_path in that order.
library :yourlib
library :otherlib
library :somelib
mtasc 'bin/SomeProjectRunner.swf' => [:somelib, :otherlib, :yourlib] do |t|
t.main = true
t.header = '800:600:24'
t.input = 'src/SomeProjectRunner.as'
end
At this time, MTASC does not support libraries that are packaged as SWC files. We are considering adding support for SWC files in the near future, if you’re interested in contributing to this feature, please let us know.
Instance Attribute Summary collapse
-
#include_std ⇒ Object
Automatically include the installation MTASC ‘std’ library to the class_path.
Instance Method Summary collapse
-
#cp=(paths) ⇒ Object
end.
-
#define ⇒ Object
:nodoc:.
-
#exclude=(file) ⇒ Object
Exclude code generation of classes listed in specified file (format is one full class path per line).
-
#frame=(number) ⇒ Object
Export AS2 classes into target frame of swf.
-
#group=(boolean) ⇒ Object
Merge classes into one single clip (this will reduce SWF size but might cause some problems if you’re using -keep or -mx).
-
#header=(string) ⇒ Object
width:height:fps:bgcolor: Create a new swf containing only compiled code and using provided header informations.
-
#infer=(boolean) ⇒ Object
Add type inference for initialized local variables.
-
#initialize_task ⇒ Object
:nodoc:.
-
#input=(file) ⇒ Object
Main source file to send compiler.
-
#keep=(boolean) ⇒ Object
Keep AS2 classes compiled by MCC into the SWF (this could cause some classes to be present two times if also compiled with MTASC).
-
#main=(boolean) ⇒ Object
Will automaticaly call static function main once all classes are registered.
-
#msvc=(boolean) ⇒ Object
Use Microsoft Visual Studio errors style formating instead of Java style (for file names and line numbers).
-
#mx=(boolean) ⇒ Object
Use precompiled MX classes (see section on V2 components below).
-
#out=(file) ⇒ Object
The SWF file that should be generated, use only in addition to the -swf parameter if you want to generate a separate SWF from the one being loaded.
-
#pack=(paths) ⇒ Object
Compile all the files contained in specified package - not recursively (eg to compile files in c:lashdemypp do mtasc -cp c:lashde -pack my/app).
-
#strict=(boolean) ⇒ Object
Use strict compilation mode which require that all variables are explicitely typed.
-
#swf=(file) ⇒ Object
Specify the swf that should be generated, OR the input SWF which contains assets.
-
#trace=(string) ⇒ Object
Specify a custom trace function.
-
#v=(boolean) ⇒ Object
Activate verbose mode, printing some additional information about compiling process.
-
#version=(number) ⇒ Object
Specify SWF version : 6 to generate Player 6r89 compatible SWF or 8 to access Flash8 features.
-
#wimp=(boolean) ⇒ Object
Adds warnings for import statements that are not used in the file.
Instance Attribute Details
#include_std ⇒ Object
Automatically include the installation MTASC ‘std’ library to the class_path.
82 83 84 |
# File 'lib/sprout/tasks/mtasc_task.rb', line 82 def include_std @include_std end |
Instance Method Details
#cp=(paths) ⇒ Object
end
13 14 15 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 13 def cp=(paths) @cp = paths end |
#define ⇒ Object
:nodoc:
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/sprout/tasks/mtasc_task.rb', line 211 def define # :nodoc: super resolve_skin self.swf = out unless swf CLEAN.add(out) # If we're on Linux, we need to manually reference # the standard library. # For more Info: http://code.google.com/p/projectsprouts/issues/detail?id=88 @include_std = true if RUBY_PLATFORM =~ /linux/i if(@include_std) # Don't inject magic/fragile version numbers or platforms here files = Dir.glob(Sprout.sprout_cache + '/sprout-mtasc-tool-.*/archive/std/') files.each do |file| class_path << file end end end |
#exclude=(file) ⇒ Object
Exclude code generation of classes listed in specified file (format is one full class path per line).
18 19 20 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 18 def exclude=(file) @exclude = file end |
#frame=(number) ⇒ Object
Export AS2 classes into target frame of swf.
23 24 25 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 23 def frame=(number) @frame = number end |
#group=(boolean) ⇒ Object
Merge classes into one single clip (this will reduce SWF size but might cause some problems if you’re using -keep or -mx).
28 29 30 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 28 def group=(boolean) @group = boolean end |
#header=(string) ⇒ Object
width:height:fps:bgcolor: Create a new swf containing only compiled code and using provided header informations. bgcolor is optional and should be 6 digits hexadecimal value.
33 34 35 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 33 def header=(string) @header = string end |
#infer=(boolean) ⇒ Object
Add type inference for initialized local variables.
38 39 40 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 38 def infer=(boolean) @infer = boolean end |
#initialize_task ⇒ Object
:nodoc:
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/sprout/tasks/mtasc_task.rb', line 84 def initialize_task # :nodoc: @include_std = false @default_gem_name = 'sprout-mtasc-tool' add_param(:cp, :paths) do |p| p.delimiter = ' ' p.description =<<EOF Add a directory path to the class path. This is the list of directories that MTASC will use to look for .as files. You can add as many class_path values as you like. This parameter is an Array, so be sure to append rather than overwrite. Even though the official MTASC compiler accepts the +cp+ paramter, we have aliased it as +class_path+, you can use either name in your scripts. mtasc 'bin/SomeProject.swf' do |t| t.class_path << 'lib/somelib' t.class_path << 'lib/otherlib' # The following is not correct: # t.class_path = 'lib/somelib' end EOF end add_param_alias(:class_path, :cp) add_param(:exclude, :file) do |p| p.delimiter = ' ' p.description = "Exclude code generation of classes listed in specified file (format is one full class path per line)." end add_param(:frame, :number) do |p| p.delimiter = ' ' p.description = "Export AS2 classes into target frame of swf." end add_param(:group, :boolean) do |p| p.hidden_value = true p.description = "Merge classes into one single clip (this will reduce SWF size but might cause some problems if you're using -keep or -mx)." end add_param(:header, :string) do |p| p.delimiter = ' ' p.description = "width:height:fps:bgcolor: Create a new swf containing only compiled code and using provided header informations. bgcolor is optional and should be 6 digits hexadecimal value." end add_param(:infer, :boolean) do |p| p.hidden_value = true p.description = "Add type inference for initialized local variables." end add_param(:keep, :boolean) do |p| p.hidden_value = true p.description = "Keep AS2 classes compiled by MCC into the SWF (this could cause some classes to be present two times if also compiled with MTASC)." end add_param(:main, :boolean) do |p| p.hidden_value = true p.description = "Will automaticaly call static function main once all classes are registered." end add_param(:msvc, :boolean) do |p| p.hidden_value = true p.description = "Use Microsoft Visual Studio errors style formating instead of Java style (for file names and line numbers)." end add_param(:mx, :boolean) do |p| p.hidden_value = true p.description = "Use precompiled MX classes (see section on V2 components below)." end add_param(:out, :file) do |p| p.delimiter = ' ' p.description = "The SWF file that should be generated, use only in addition to the -swf parameter if you want to generate a separate SWF from the one being loaded" end add_param(:pack, :paths) do |p| p.delimiter = ' ' p.description = "Compile all the files contained in specified package - not recursively (eg to compile files in c:\flash\code\my\app do mtasc -cp c:\flash\code -pack my/app)." end add_param(:strict, :boolean) do |p| p.hidden_value = true p.description = "Use strict compilation mode which require that all variables are explicitely typed." end add_param(:swf, :file) do |p| p.delimiter = ' ' p.required = true p.description =<<EOF Specify the swf that should be generated, OR the input SWF which contains assets. If this parameter is not set, the MTASCTask will do the following: * Iterate over it's prerequisites and set the -swf parameter to the output of the first SWFMillTask found * If no SWFMillTask instances are in this task prerequisites and the -swf parameter has not been set, it will be set to the same as the -out parameter EOF end add_param(:trace, :string) do |p| p.delimiter = ' ' p.description = "Specify a custom trace function. (see Trace Facilities), or no disable all the traces." end add_param(:version, :number) do |p| p.delimiter = ' ' p.description = "Specify SWF version : 6 to generate Player 6r89 compatible SWF or 8 to access Flash8 features." end add_param(:v, :boolean) do |p| p.hidden_value = true p.description = "Activate verbose mode, printing some additional information about compiling process. This parameter has been aliased as +verbose+" end add_param_alias(:verbose, :v) add_param(:wimp, :boolean) do |p| p.hidden_value = true p.description = "Adds warnings for import statements that are not used in the file." end # This must be the last item in this list add_param(:input, :file) do |p| p.hidden_name = true p.required = true p.description = "Main source file to send compiler" end self.out = name.to_s.dup end |
#input=(file) ⇒ Object
Main source file to send compiler
107 108 109 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 107 def input=(file) @input = file end |
#keep=(boolean) ⇒ Object
Keep AS2 classes compiled by MCC into the SWF (this could cause some classes to be present two times if also compiled with MTASC).
43 44 45 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 43 def keep=(boolean) @keep = boolean end |
#main=(boolean) ⇒ Object
Will automaticaly call static function main once all classes are registered.
48 49 50 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 48 def main=(boolean) @main = boolean end |
#msvc=(boolean) ⇒ Object
Use Microsoft Visual Studio errors style formating instead of Java style (for file names and line numbers).
53 54 55 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 53 def msvc=(boolean) @msvc = boolean end |
#mx=(boolean) ⇒ Object
Use precompiled MX classes (see section on V2 components below).
58 59 60 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 58 def mx=(boolean) @mx = boolean end |
#out=(file) ⇒ Object
The SWF file that should be generated, use only in addition to the -swf parameter if you want to generate a separate SWF from the one being loaded
63 64 65 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 63 def out=(file) @out = file end |
#pack=(paths) ⇒ Object
Compile all the files contained in specified package - not recursively (eg to compile files in c:lashdemypp do mtasc -cp c:lashde -pack my/app).
68 69 70 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 68 def pack=(paths) @pack = paths end |
#strict=(boolean) ⇒ Object
Use strict compilation mode which require that all variables are explicitely typed.
73 74 75 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 73 def strict=(boolean) @strict = boolean end |
#swf=(file) ⇒ Object
Specify the swf that should be generated, OR the input SWF which contains assets.
If this parameter is not set, the MTASCTask will do the following:
-
Iterate over it’s prerequisites and set the -swf parameter to the output of the first SWFMillTask found
-
If no SWFMillTask instances are in this task prerequisites and the -swf parameter has not been set, it will be set to the same as the -out parameter
82 83 84 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 82 def swf=(file) @swf = file end |
#trace=(string) ⇒ Object
Specify a custom trace function. (see Trace Facilities), or no disable all the traces.
87 88 89 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 87 def trace=(string) @trace = string end |
#v=(boolean) ⇒ Object
Activate verbose mode, printing some additional information about compiling process. This parameter has been aliased as verbose
97 98 99 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 97 def v=(boolean) @v = boolean end |
#version=(number) ⇒ Object
Specify SWF version : 6 to generate Player 6r89 compatible SWF or 8 to access Flash8 features.
92 93 94 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 92 def version=(number) @version = number end |
#wimp=(boolean) ⇒ Object
Adds warnings for import statements that are not used in the file.
102 103 104 |
# File 'lib/sprout/tasks/mtasc_rdoc.rb', line 102 def wimp=(boolean) @wimp = boolean end |