Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/spacemeowx2/flash-emu
- Owner: spacemeowx2
- License: mit
- Created: 2017-10-25T08:52:58.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-11T18:07:31.000Z (over 6 years ago)
- Last Synced: 2024-10-31T01:35:06.523Z (14 days ago)
- Language: TypeScript
- Size: 8.8 MB
- Stars: 20
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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))
```