Class: FlashSDK::MXMLC

Inherits:
CompilerBase
  • Object
show all
Defined in:
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

Instance Attribute Summary

Attributes inherited from CompilerBase

#fcsh_port, #use_fcsh

Instance Method Summary collapse

Methods inherited from CompilerBase

#accessible, #actionscript_file_encoding, #allow_source_path_overlap, #as3, #benchmark, #context_root, #contributor, #creator, #date, #debug, #debug_password, #default_background_color, #default_css_url, #default_frame_rate, #default_script_limits, #default_size, #define_conditional, #description, #dump_config, #el, #es, #external_library_path, #externs, #file_specs, #fonts_languages_language_range, #fonts_managers, #fonts_max_cached_fonts, #fonts_max_glyphs_per_face, #frames_frame, #generate_frame_loader, #headless_server, #include_libraries, #include_path, #includes, #incremental, #keep_as3_metadata, #keep_generated_actionscript, #l, #language, #lazy_init, #library_path, #license, #link_report, #load_config, #load_externs, #locale, #localized_description, #localized_title, #namespaces_namespace, #optimize, #output, #publisher, #raw_metadata, #resource_bundle_list, #rsl, #rslp, #runtime_shared_libraries, #runtime_shared_library_path, #services, #show_actionscript_warnings, #show_binding_warnings, #show_deprecation_warnings, #show_shadowed_device_font_warnings, #show_unused_type_selector_warnings, #source_path, #static_link_runtime_shared_libraries, #static_rsls, #strict, #target_player, #theme, #title, #use_network, #use_resource_bundle_metadata, #verbose_stacktraces, #verify_digests, #warn_warning_type, #warnings

Instance Method Details

#default_prefixObject

The default prefix for shell params.



108
# File 'lib/flashsdk/mxmlc.rb', line 108

set :default_prefix, '-'

#executableObject

The default executable target.



126
# File 'lib/flashsdk/mxmlc.rb', line 126

set :executable, :mxmlc

#executeObject



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

def execute
  duration = Benchmark.measure { super }
  Sprout.stdout.puts "[MXMLC] Compilation complete in #{duration.real} seconds." unless use_fcsh?
end

#include_resource_bundlesObject

Specifies the resource bundles to include when compiling a locale SWF. All resource bundles specified with this option must be in the compiler’s source path. You specify this using the source-path compiler option.

For more information on using resource bundles, see Localizing Flex Applications (livedocs.adobe.com/flex/201/html/l10n_076_1.html#129288) in Flex 2 Developer’s Guide.



104
# File 'lib/flashsdk/mxmlc.rb', line 104

add_param :include_resource_bundles, Files

#inputObject

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



97
# File 'lib/flashsdk/mxmlc.rb', line 97

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

#pkg_nameObject

The the Ruby file that will load the expected Sprout::Specification.

Default value is ‘flex4’



116
# File 'lib/flashsdk/mxmlc.rb', line 116

set :pkg_name, 'flex4'

#pkg_versionObject

The default pkg version



121
# File 'lib/flashsdk/mxmlc.rb', line 121

set :pkg_version, ">= #{FlashSDK::VERSION}"

#use_fcsh?Boolean

Returns:

  • (Boolean)


133
134
135
136
137
138
# File 'lib/flashsdk/mxmlc.rb', line 133

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