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:\dev\4.y\frameworks\projects\framework\src\mx\managers\SystemManager.as:278]
at mx.managers::SystemManager/preloader_preloaderDocFrameReadyHandler()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\SystemManager.as:2627]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.preloaders::Preloader/timerHandler()[E:\dev\4.y\frameworks\projects\framework\src\mx\preloaders\Preloader.as:515]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
デスクトップアプリケーションであるため、サーバー側ではない限り、スクリプト側またはコマンドライン側の両方からswfファイルランタイムを作成する最良の方法を教えてください。
どうもありがとう