如何使用as3(Flash CS5)自动保存(不使用对话框)图像

Alo*_*lon 3 flash autosave actionscript-3 printscreen

它看起来像一个简单的问题,但我找不到答案.

我有这个代码:

import com.adobe.images.PNGEncoder;
var fr:FileReference = new FileReference();

var pngSource:BitmapData = new BitmapData (stage.width, stage.height);
pngSource.draw(sketch_mc);

var ba:ByteArray = PNGEncoder.encode(pngSource);
fr.save(ba,'alon20.png');
Run Code Online (Sandbox Code Playgroud)

这为我省去了一张图片.我希望它自动保存它,而不是像现在那样打开一个对话框.我希望这种情况发生的原因是因为我想在渲染时间拍摄每一帧(用它制作一部电影).

我错过了什么?

Sim*_*aud 12

在纯闪存中,如果没有对话框,则无法保存文件.但是,如果它是桌面应用程序,则使用Air:

var fs : FileStream = new FileStream();
var targetFile : File = File.desktopDirectory.resolvePath('alon20.png');
fs.open(targetFile, FileMode.WRITE);
fs.writeBytes(ba);
fs.close();
Run Code Online (Sandbox Code Playgroud)