Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/spacemeowx2/flash-emu

Run flascc in js
https://github.com/spacemeowx2/flash-emu

Last synced: 3 days ago
JSON representation

Run flascc in js

Awesome Lists containing this project

README

        

# flash-emu
[![Downloads](https://img.shields.io/npm/dt/flash-emu.svg)](https://www.npmjs.com/package/flash-emu)
[![Version](https://img.shields.io/npm/v/flash-emu.svg)](https://www.npmjs.com/package/flash-emu)
[![License](https://img.shields.io/npm/l/flash-emu.svg)](https://www.npmjs.com/package/flash-emu)

Run .swf file generated by CrossBridge/FlasCC/Alchemy.

## Usage

```javascript
// run it https://github.com/spacemeowx2/flash-emu-demo
const fs = require('fs')
const util = require('util')
const readFile = util.promisify(fs.readFile)
const FlashEmu = require('flash-emu')
FlashEmu.PLAYERGLOBAL = 'node_modules/flash-emu/lib/playerglobal.abc'
FlashEmu.BUILTIN = 'node_modules/flash-emu/lib/builtin.abc'
const emu = new FlashEmu({
async readFile (filename) {
const buf = await readFile(filename)
return new Uint8Array(buf).buffer
}
})
const vm = emu.getVM()
emu.runSWF('example.swf', false).then(() => {
const CModule = vm.getProxy(emu.getProperty('sample.mp', 'CModule'))
CModule.callProperty('startAsync')
let somePtr = CModule.callProperty('malloc', 4)
console.log('ptr:', somePtr)
CModule.callProperty('free', somePtr)
}).catch(e => console.error(e))
```