Class: FlashSDK::MXMLC

Inherits:
CompilerBase show all
Defined in:
flashsdk/lib/flashsdk/mxmlc.rb

Overview

The MXMLC task provides a rake front end to the Flex MXMLC command line compiler. This task is integrated with the LibraryTask so that if any dependencies are library tasks, they will be automatically added to the library_path or source_path depending on whether they provide a swc or sources.

The entire MXMLC advanced interface has been provided here. All parameter names should be identical to what is available on the regular compiler except dashes have been replaced by underscores.

The following example can be pasted in a file named 'rakefile.rb' which should be placed in the same folder as an ActionScript 3.0 class named 'SomeProject.as' that extends flash.display.Sprite.

# Create a remote library dependency on the corelib swc.
library :corelib

# Alias the compilation task with one that is easier to type
task :compile => 'SomeProject.swf'

# Create an MXMLC named for the output file that it creates. This task depends on the
# corelib library and will automatically add the corelib.swc to it's library_path
mxmlc 'bin/SomeProject.swf' => :corelib do |t|
  t.input                     = 'src/SomeProject.as'
  t.default_size              = '800,600'
  t.default_background_color  = "#FFFFFF"
  t.library_path              << 'lib/SomeLibrary.swc'
  t.source_path               << 'lib/otherlib'
end

Remember that Rake files are really just regular Ruby code, so if you want to have some configuration information shared by multiple build tasks, just define a method like:

def configure_tasks t
  t.library_path << 'lib/SomeLibrary.swc'
  t.source_path << 'lib/otherlib'
end

desc "Compile the project"
mxmlc 'bin/SomeProject.swf' do |t|
  configure_tasks t
  t.input = 'src/SomeProject.as'
end

desc "Compile the test harness"
mxmlc 'bin/SomeProjectRunner.swf' => :asunit4 do |t|
  configure_tasks t
  t.input = 'src/SomeProjectRunner.as'
end

FCSH

Building with MXMLC can be quite slow. If you'd like to measure your build times in fractions of a second rather than minutes, you can use the Flex Compiler SHell (FCSH).

Sprouts makes it incredibly easy to use FCSH, following are some simple instructions:

Open up a new terminal, cd into your project directory and run:

rake fcsh:start

Open up a new terminal, cd into your project directory and run whatever Rake task depends on at least one MXMLC task, and call the fcsh task first. This can be done on the terminal like this:

rake fcsh test

More information about FCSH can be found on the Project Sprouts Blog.

Flex Debugger (FDB)

Like FCSH, the Flex Debugger can be initiated by calling (or depending on) the fdb Rake task.

rake fdb test

This will drop you into the Flex Debugger shell environment, you can type help at anytime to learn more about what commands are available.

You can also type quit or hit CTRL+C to exit FDB.

See Also:

Direct Known Subclasses

AMXMLC

Constant Summary

Constants included from Sprout::Executable

DEFAULT_FILE_EXPRESSION, DEFAULT_PREFIX, DEFAULT_SHORT_PREFIX

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from CompilerBase

#execute_delegate, #execute_with_fcsh, #library_added, #prepare, #update_fcsh

Methods inherited from Sprout::Executable::Base

add_param, add_param_alias, #binary_path, #binary_path=, #create_outer_task, #default_file_expression, #execute_delegate, #from_hash, #initialize, #library_added, #parse!, #parse_extra_options!, #parse_rake_task_arg, #prepare, set, static_default_value_collection, static_parameter_collection, #stderr, #stderr=, #stdout, #stdout=, #system_execute, #to_hash, #to_help, #to_rake, #to_shell, #update_rake_task_name_from_args

Methods included from Sprout::Concern

#append_features, extended, #included

Constructor Details

This class inherits a constructor from Sprout::Executable::Base

Instance Attribute Details

- (File) input

Main source file to send compiler. This must be the last item in this list

Returns:

  • (File)

    An instance of File



# File ''

add_param :input, File, { :required => true, :hidden_name => true }

Instance Method Details

- (Object) execute



121
122
123
124
125
126
# File 'flashsdk/lib/flashsdk/mxmlc.rb', line 121

def execute
  start = Time.now
  super
  duration = (Time.now - start).seconds
  Sprout.stdout.puts "[MXMLC] Compilation complete in #{duration} seconds." unless use_fcsh?
end

- (Boolean) use_fcsh?

Returns:



128
129
130
131
132
133
# File 'flashsdk/lib/flashsdk/mxmlc.rb', line 128

def use_fcsh?
  # Check as string b/c this is
  # how the boolean value comes
  # accross the command line input.
  ENV['USE_FCSH'].to_s == 'true'
end