How autosave (no dialog) images using as3 (Flash CS5)

This seems like a simple question, but I cannot 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 the image. I want it to be autosave and not open the dialog box as it is now. the reason I want this to happen is that I want to take a snapshot of each frame during rendering (make a movie out of it).

What am I missing?

+3
source share
1 answer

In a clean flash, you cannot save a file without a dialog box. However, if this is a desktop application, you are using Air:

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

All Articles