Skip to content

spacemeowx2/flash-emu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

597b5d8 · Jul 11, 2018

History

7 Commits
Oct 25, 2017
Oct 25, 2017
Jul 11, 2018
Oct 25, 2017
Oct 25, 2017
Oct 25, 2017
Oct 25, 2017
Oct 26, 2017
Oct 25, 2017
Oct 26, 2017
Oct 25, 2017
Oct 26, 2017
Oct 26, 2017
Oct 25, 2017
Oct 25, 2017
Oct 25, 2017
Oct 25, 2017

Repository files navigation

flash-emu

Downloads Version License

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

Usage

// 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))