Class Sprout::MTASCTask
In: bundles/as2/lib/sprout/tasks/mtasc_documentation.rb
bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb
bundles/as2/lib/sprout/tasks/mtasc_task.rb
Parent: ToolTask

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.

Methods

cp=   cp=   exclude=   exclude=   frame=   frame=   group=   group=   header=   header=   infer=   infer=   input=   input=   keep=   keep=   main=   main=   msvc=   msvc=   mx=   mx=   out=   out=   pack=   pack=   resolve_library   resolve_skin   strict=   strict=   swf=   swf=   trace=   trace=   v=   v=   version=   version=   wimp=   wimp=  

Attributes

include_std  [RW]  Automatically include the installation MTASC ‘std’ library to the class_path.

Public Instance methods

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

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 13
def cp=(paths)
  @cp = paths
end

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

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 13
def cp=(paths)
  @cp = paths
end

Exclude code generation of classes listed in specified file (format is one full class path per line).

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 18
def exclude=(file)
  @exclude = file
end

Exclude code generation of classes listed in specified file (format is one full class path per line).

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 18
def exclude=(file)
  @exclude = file
end

Export AS2 classes into target frame of swf.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 23
def frame=(number)
  @frame = number
end

Export AS2 classes into target frame of swf.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 23
def frame=(number)
  @frame = number
end

Merge classes into one single clip (this will reduce SWF size but might cause some problems if you‘re using -keep or -mx).

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 28
def group=(boolean)
  @group = boolean
end

Merge classes into one single clip (this will reduce SWF size but might cause some problems if you‘re using -keep or -mx).

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 28
def group=(boolean)
  @group = boolean
end

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.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 33
def header=(string)
  @header = string
end

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.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 33
def header=(string)
  @header = string
end

Add type inference for initialized local variables.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 38
def infer=(boolean)
  @infer = boolean
end

Add type inference for initialized local variables.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 38
def infer=(boolean)
  @infer = boolean
end

Main source file to send compiler

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 107
def input=(file)
  @input = file
end

Main source file to send compiler

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 107
def input=(file)
  @input = file
end

Keep AS2 classes compiled by MCC into the SWF (this could cause some classes to be present two times if also compiled with MTASC).

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 43
def keep=(boolean)
  @keep = boolean
end

Keep AS2 classes compiled by MCC into the SWF (this could cause some classes to be present two times if also compiled with MTASC).

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 43
def keep=(boolean)
  @keep = boolean
end

Will automaticaly call static function main once all classes are registered.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 48
def main=(boolean)
  @main = boolean
end

Will automaticaly call static function main once all classes are registered.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 48
def main=(boolean)
  @main = boolean
end

Use Microsoft Visual Studio errors style formating instead of Java style (for file names and line numbers).

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 53
def msvc=(boolean)
  @msvc = boolean
end

Use Microsoft Visual Studio errors style formating instead of Java style (for file names and line numbers).

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 53
def msvc=(boolean)
  @msvc = boolean
end

Use precompiled MX classes (see section on V2 components below).

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 58
def mx=(boolean)
  @mx = boolean
end

Use precompiled MX classes (see section on V2 components below).

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 58
def mx=(boolean)
  @mx = boolean
end

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

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 63
def out=(file)
  @out = file
end

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

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 63
def out=(file)
  @out = file
end

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).

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 68
def pack=(paths)
  @pack = paths
end

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).

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 68
def pack=(paths)
  @pack = paths
end

Use strict compilation mode which require that all variables are explicitely typed.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 73
def strict=(boolean)
  @strict = boolean
end

Use strict compilation mode which require that all variables are explicitely typed.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 73
def strict=(boolean)
  @strict = boolean
end

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

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 82
def swf=(file)
  @swf = file
end

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

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 82
def swf=(file)
  @swf = file
end

Specify a custom trace function. (see Trace Facilities), or no disable all the traces.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 87
def trace=(string)
  @trace = string
end

Specify a custom trace function. (see Trace Facilities), or no disable all the traces.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 87
def trace=(string)
  @trace = string
end

Activate verbose mode, printing some additional information about compiling process. This parameter has been aliased as verbose

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 97
def v=(boolean)
  @v = boolean
end

Activate verbose mode, printing some additional information about compiling process. This parameter has been aliased as verbose

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 97
def v=(boolean)
  @v = boolean
end

Specify SWF version : 6 to generate Player 6r89 compatible SWF or 8 to access Flash8 features.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 92
def version=(number)
  @version = number
end

Specify SWF version : 6 to generate Player 6r89 compatible SWF or 8 to access Flash8 features.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 92
def version=(number)
  @version = number
end

Adds warnings for import statements that are not used in the file.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_documentation.rb, line 102
def wimp=(boolean)
  @wimp = boolean
end

Adds warnings for import statements that are not used in the file.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_rdoc.rb, line 102
def wimp=(boolean)
  @wimp = boolean
end

Protected Instance methods

Handle prerequisite libraries by adding them to the source path

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_task.rb, line 249
    def resolve_library(library_task)
      #TODO: Add support for libraries that don't get
      # copied into the project
      path = library_task.project_path
      if(path.match(/.swc$/))
        raise MTASCError.new("MTASC doesn't support SWC libraries, but this should be relatively easy to implement. Please let us know if you're interested in this feature!")
      else
        class_path << library_task.project_path
      end
    end

Iterate over prerequisites until you find the first SWFMillTask instance, and set self.swf = instance.output so that the skin gets compiled in.

[Source]

# File bundles/as2/lib/sprout/tasks/mtasc_task.rb, line 238
    def resolve_skin
      prerequisites.each do |prereq|
        instance = Rake::application[prereq]
        if(instance.is_a?(SWFMillTask))
          self.swf = instance.output
          break
        end
      end
    end

[Validate]