开发者

How to autosave (without dialog box) an image using as3 (Flash CS5)

开发者 https://www.devze.com 2023-03-05 21:41 出处:网络
开发者_如何学运维It looks like an easy question but I can\'t find the answer. I have this code:

开发者_如何学运维It looks like an easy question but I can't find the answer.

I have this code:

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');

which saves me an image. I want it to autosave it and not to open a dialog box as it does now. the reason I want that to happen is because I want to take picture of every frame in render time (to make a movie out of it).

What am I missing?


In pure flash, you can't save a file without a dialogbox. However, if it's a desktop app, you use Air :

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号