从adobeAir应用程序编译SWF运行时



我在从adobe-air应用程序创建swf文件运行时遇到问题。例如,我使用https://github.com/jamesflorentino/Flip-Planes-AS3,我已经将Sprite扩展转换为MovieClip,动画运行得很好。现在我想让动画可以由用户保存为swf文件。

我已经用这样的脚本尝试过as3swf:

private function createSwf():void{
    //let make example the Main class is taken from github above
    var _main:Main = new Main();
    // in this case i use AS3SWF plugin
    var _swf:SWF = new SWF(_main.loaderInfo.bytes);
    // this is for copy byteArray from the _swf convertor
    var buffer:ByteArray = new ByteArray();
    _swf.publish(buffer);        
    saveToDesktop(buffer);
}
private function saveToDesktop(_ba:ByteArray):void{
  // create the file on the desktop
  var myFile:File = File.desktopDirectory.resolvePath("demo.swf");
  // create a FileStream to write the file
  var fs:FileStream = new FileStream();
  // add a listener so you know when its finished saving
  fs.addEventListener(Event.CLOSE, fileWritten);
  // open the file
  fs.openAsync(myFile, FileMode.WRITE);   
  // write the bytearray to it
  fs.writeBytes(_ba);
  // close the file
  fs.close();
}
private function fileWritten(e:Event):void{
  trace("new swf file is created");
}

在所有这些过程之后,我在桌面文件夹中生成了名为demo.swf的swf,但当我打开文件时,它只是一个白色背景,并显示错误消息:

VerifyError: Error #1014: Class flash.events::NativeWindowBoundsEvent could not be found.
at flash.display::MovieClip/nextFrame()
at mx.managers::SystemManager/deferredNextFrame()[E:dev4.yframeworksprojectsframeworksrcmxmanagersSystemManager.as:278]
at mx.managers::SystemManager/preloader_preloaderDocFrameReadyHandler()[E:dev4.yframeworksprojectsframeworksrcmxmanagersSystemManager.as:2627]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.preloaders::Preloader/timerHandler()[E:dev4.yframeworksprojectsframeworksrcmxpreloadersPreloader.as:515]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

请帮助我创建swf文件运行时的最佳方式是什么,无论是从脚本端还是命令行端,只要不是服务器端,因为它是桌面应用程序。

非常感谢

在运行时创建SWF与获取动画的内存中字节数组表示并使用SWF扩展进行保存不同。

如果你想从AIR构建一个SWF;您可以考虑将Flex框架与您的应用程序绑定,并使用NativeProcess来触发mxmlc以生成SWF。您将需要源代码[或SWC]来完成这项工作,但是,它不能与您正在运行的应用程序中已经编译的资产/类一起使用。

或者,您可能想要查看SWF的文件格式,然后从AIR应用程序手动创建它。我毫不怀疑这是可能的,但我不认为这是微不足道的。

最新更新