#actionscript #swf #flash

rascal

A parser and compiler for Flash ActionScript 2 files into SWFs

14 releases

Uses new Rust 2024

new 0.3.2 May 13, 2026
0.3.1 May 13, 2026
0.2.7 May 9, 2026
0.2.3 Apr 30, 2026
0.1.2 Aug 13, 2021

#329 in Parser implementations

Download history 496/week @ 2026-01-29 13/week @ 2026-04-16 53/week @ 2026-04-23 1477/week @ 2026-04-30 1009/week @ 2026-05-07

2,552 downloads per month
Used in rascal_cli

MIT/Apache

495KB
14K SLoC

Rascal

License

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.

Command Line Usage

A basic CLI is provided for compiling ActionScript files to SWF files.

Installation

  • Clone the repository
  • Run cargo install --path crates/cli --release

Usage

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 named some.ClassName (expected to be available at some/ClassName.as) into a SWF file.
    • The classpath defaults to working directory, but can be specified via the --classpath flag.
    • 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.

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, else output.swf
  • -v 10/--swf-version 10 - The version of SWF file to produce
  • --frame-rate 30 - The frame rate of the SWF file
    • This defaults to 24

Library

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

License

Rascal is licensed MIT or Apache-2.0, at your option.

Dependencies

~9–15MB
~362K SLoC