A Flash Player emulator written in Rust
Go to file
Mike Welsh 0c9f79cc91 Don't auto-parse AVM1 ops in DoAction tags 2017-11-17 18:13:33 -08:00
src Don't auto-parse AVM1 ops in DoAction tags 2017-11-17 18:13:33 -08:00
tests/swfs ActionScript 3 (AVM2) parsing 2017-08-26 01:18:51 -07:00
.gitignore Add rustfmt.toml to .gitignore 2016-08-29 13:36:14 -07:00
.travis.yml Update Travis config; Fix some clippy lints 2017-07-03 21:50:47 -07:00
Cargo.toml Upgrade xz2 to latest 2017-07-05 20:34:12 -07:00
LICENSE-APACHE Change license to MIT/Apache-2.0 2016-09-13 11:23:29 -07:00
LICENSE-MIT Change license to MIT/Apache-2.0 2016-09-13 11:23:29 -07:00
README.md Change license to MIT/Apache-2.0 2016-09-13 11:23:29 -07:00

README.md

swf

Build Status

A Rust library for reading and writing the Adobe Flash SWF file format.

# Cargo.toml
[dependencies]
swf = "0.1"

Reading

extern crate swf;

use std::io::BufReader;
use std::fs::File;

fn main() {
    let f = File::open("file.swf").unwrap();
    let reader = BufReader::new(f);
    let swf = swf::read_swf(reader).unwrap();
    println!("The SWF has {} frames", swf.num_frames);
}

Writing

extern crate swf;

use std::io::BufWriter;
use std::fs::File;
use swf::*;

fn main() {
    let f = File::create("file.swf").unwrap();
    let writer = BufWriter::new(f);
    let swf = Swf {
        version: 6,
        compression: Compression::Zlib,
        stage_size: Rectangle { x_min: 0f32, x_max: 400f32, y_min: 0f32, y_max: 400f32 },
        frame_rate: 60f32,
        num_frames: 1,
        tags: vec![
            Tag::SetBackgroundColor(Color { r: 255, g: 0, b: 0, a: 255 }),
            Tag::ShowFrame
        ]
    };
    swf::write_swf(&swf, writer).unwrap();
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.