AS3 FileReference.save()在本地,但没有测试在浏览器中,当工作 [英] AS3 FileReference.save() works when testing locally but not in the browser

查看:160
本文介绍了AS3 FileReference.save()在本地,但没有测试在浏览器中,当工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个绘画应用程序,当用户想要的救他的画,他简单地点击保存按钮,弹出一个对话框 - 或者应该做的。

I have created a painting app and when the user want's to save his drawing he simply hits the save button and a dialog pops up - or should do.

在本地开发计算机上测试它是没有问题,但每当应用程序在浏览器中加载它不会工作。即使我在浏览器中加载本地的SWF文件将无法正常工作。

When testing locally on dev machine it's no problem but whenever the app is loaded in a browser it won't work. Even if I load the local SWF file in a browser it won't work.

下面code是什么,我用它来保存文件,并为表示它工作正常,在本地,但每当它进入一个浏览器,它dosen't.The保存对话框根本不会弹出。

The following code is what I use to save the file and as said it works fine locally but whenever it goes into a browser it dosen't.The save dialog simply never pops up.

有什么建议?

var bitmapData:BitmapData = new BitmapData(canvas.width, canvas.height);
bitmapData.draw(canvas);
var jpg:JPEGEncoder = new JPEGEncoder(100);
var ba:ByteArray = jpg.encode(bitmapData);

file = new FileReference();
file.addEventListener(Event.COMPLETE, fileSaveComplete);
file.addEventListener(IOErrorEvent.IO_ERROR, error);
file.save(ba, 'FileName.jpg');

运行Flash插件11和编译为10.2 BTW。

Running FlashPlayer 11 and compiling to 10.2 BTW.

推荐答案

这是一个安全问题。保存文件对话框窗口现在只能开一个结果的直接用户的事件,如点击。一种解决方法是通知在创建图像时的用户,并问他是否想保存到本地文件。如果他点击是的,你叫保存方式。

That is a security issue. A save file dialog window can now only be opened as a result to a direct user event, like a click. One solution is to notify the user when the image is created, and ask if he wants to save the file locally. And if he clicks yes, you call the save method.

下面是对这种变化的详细信息:

Here's more info on this change:

<一个href="http://www.bogdanmanate.com/2010/05/12/flex-error-2176-when-using-filereference/">http://www.bogdanmanate.com/2010/05/12/flex-error-2176-when-using-filereference/

希望这有助于。有一个好的一天。

Hope this helps. Have a good day.

这篇关于AS3 FileReference.save()在本地,但没有测试在浏览器中,当工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆