如何使用as3(Flash CS5)自动保存(不使用对话框)图像
发布时间:2020-12-15 07:22:15 所属栏目:百科 来源:网络整理
导读:它看起来像一个简单的问题,但我找不到答案. 我有这个代码: 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:Byt
它看起来像一个简单的问题,但我找不到答案.
我有这个代码: 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'); 这为我省去了一张图片.我希望它自动保存它,而不是像现在那样打开一个对话框.我希望这种情况发生的原因是因为我想在渲染时间拍摄每一帧(用它制作一部电影). 我错过了什么? 解决方法
在纯闪存中,如果没有对话框,则无法保存文件.但是,如果它是桌面应用程序,则使用Air:
var fs : FileStream = new FileStream(); var targetFile : File = File.desktopDirectory.resolvePath('alon20.png'); fs.open(targetFile,FileMode.WRITE); fs.writeBytes(ba); fs.close(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |