Rascal is an open source ActionScript 2 compiler, with aspirations for further ActionScript and SWF editing capabilities in the future.
It was primarily developed for use with Ruffle, and allows the authoring and editing of ActionScript 1 and 2 content without the need to hunt down a copy of Flash from eBay.
A basic CLI is provided for compiling ActionScript files to SWF files.
- Clone the repository
- Run
cargo install --path crates/cli --release
For full CLI usage, run rascal --help.
There are two kinds of inputs, and they are intermixable.
rascal foo.as- Compiles a script (not a class, loose code) into a SWF file.- Multiple script files can be specified, and they will execute in the order they are specified.
rascal -c some.ClassName- Compiles a class namedsome.ClassName(expected to be available atsome/ClassName.as) into a SWF file.- The classpath defaults to working directory, but can be specified via the
--classpathflag. - Multiple class names can be specified, and they will be loaded in the order they are specified.
- If one (and only one) class has a
static function main(), it will be executed as the entry point to the swf.
- The classpath defaults to working directory, but can be specified via the
Various options about the output are available:
-o foo.swf/--output foo.swf- The output SWF file- This defaults to either the first script file +
.swf, elseoutput.swf
- This defaults to either the first script file +
-v 10/--swf-version 10- The version of SWF file to produce- This defaults to 15, which corresponds to Flash Player 11.2
--frame-rate 30- The frame rate of the SWF file- This defaults to 24
Super simple API right now:
use rascal::ProgramBuilder;
use rascal::provider::FileSystemSourceProvider;
fn main() {
// A source provider is responsible for resolving files during compilation.
// A file system source provider is provided for convenience, which takes a root directory as a "class path".
let source_provider = FileSystemSourceProvider::with_root(PathBuf::from("."));
let program = ProgramBuilder::new(source_provider)
.add_script("foo.as") // Adds `foo.as` as a script to run
.add_class("some.ClassName") // Adds `some/ClassName.as` as a class to load
.build()?;
let compiled_program = program.compile(/* swf_version= */ 15);
let swf = compiled_program.to_swf(/* frame_rate= */ 24.0)?;
// Do something with the SWF file.
}Rascal is licensed MIT or Apache-2.0, at your option.