请参阅我的代码。我阅读了许多博客,还检查了我的 XML 权限。图像导出到我的电脑,但是当我发布 APK 时。我把它安装在我的手机上。我的代码无法正常工作。我在我的画廊中看不到任何保存图像和文件夹。我能做些什么。
stop();
import flash.filesystem.File;
import flash.filesystem.FileStream;
import flash.filesystem.FileMode;
import flash.net.FileReference; //add this
import com.adobe.images.JPGEncoder;
import com.adobe.images.PNGEncoder;
var date: Date = new Date();
this.addEventListener(MouseEvent.CLICK, onSavePictureButtonClicked);
function onSavePictureButtonClicked(event: MouseEvent): void {
var ImageSaverBMD: BitmapData = new BitmapData(Object(parent).mc_canvas.width,
Object(parent).mc_canvas.height);
ImageSaverBMD.draw(Object(parent).mc_canvas);
var jpgEncoder: JPGEncoder = new JPGEncoder(100);
var jpgBytes: ByteArray = jpgEncoder.encode(ImageSaverBMD);
Object(parent).mc_canvas.scaleX = 1;
Object(parent).mc_canvas.scaleY = 1;
var file_name: String;
if (date.getMonth() < 12)
file_name = '0' + date.getMonth() + '-';
else
file_name = date.getMonth() + '-';
if (date.getDate() < 10)
file_name += '0' + date.getDate() + '-' + date.getFullYear();
else
file_name += date.getDate() + '-' + date.getFullYear();
file_name = 'Picture ' +
file_name + '_' +
date.getHours() + '.' +
date.getMinutes();
var myFile: File = File.userDirectory.resolvePath("KidsColoring/" + file_name + ".jpg");
trace(myFile.nativePath); // C:\Documents and Settings\userName\My Documents\AIR Test
Object(parent).nativee.text = myFile.nativePath;
var fs: FileStream = new FileStream();
fs.open(myFile, FileMode.WRITE);
fs.writeBytes(jpgBytes, 0, jpgBytes.length);
fs.close();
Object(parent).SaveDialog.gotoAndPlay(2);
}