HTML5 FileApi + FileReader - Feed<对象>与 SWF对象>
我想使用 HTML5 FileApi 将 SWF 读取到 OBJECT
(或 EMBED
,如果这样做更好?)。
我当前的代码在 Chrome/Iron(唯一稳定浏览器,也支持 xmlhttprequest v2 FormData)上崩溃。我让它将图像数据读取到即时创建的 IMG 中。但该对象会使浏览器中的当前选项卡崩溃。
else if (file.type == "application/x-shockwave-flash") {
var show = document.createElement("object");
show.type = "application/x-shockwave-flash"
show.style.width = "100%";
show.style.height = "100%";
show.id = "thumb";
document.getElementById("thumbnails").appendChild(show);
var reader = new FileReader();
reader.onload = (function (aImg) {
return function (e) { aImg.data = e.target.result; };
})(show);
reader.readAsDataURL(file);
我真的读到了 object.data
部分吗?怎样做才是正确的?有人知道吗?还是这不完整,我必须等待更好的实施?
I want to use the HTML5 FileApi to read a SWF to an OBJECT
(or EMBED
, if it's better to do?).
My current code crashes on Chrome/Iron (the only stable browser which also supports the xmlhttprequest v2 FormData). I got it to read image data into a on-the-fly created IMG. But the object one crashes the current tab in the browser.
else if (file.type == "application/x-shockwave-flash") {
var show = document.createElement("object");
show.type = "application/x-shockwave-flash"
show.style.width = "100%";
show.style.height = "100%";
show.id = "thumb";
document.getElementById("thumbnails").appendChild(show);
var reader = new FileReader();
reader.onload = (function (aImg) {
return function (e) { aImg.data = e.target.result; };
})(show);
reader.readAsDataURL(file);
Do I really read to the object.data
part? How is it done right? Anybody know? Or is this incomplete and I have to wait for better implementation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议尝试一些事情(按照复杂性增加的顺序):
data:
URI 设置它,createElement
创建对象,而是将所有属性构造为 HTML 字符串(包括上面的 base64 建议)的后者的选项更加密集,并且需要您可能希望避免的服务器往返 - 只是您可能需要考虑更多选项。
ActionScript 3 有一个
Loader
这也可能有用。我不知道它是否支持data:
URI,但如果支持,您可以编写一个引导加载程序 SWF,它直接运行本地 swf 文件的内容。A few things I'd recommend trying (in order of increasing complexity):
data:
URI,createElement
, construct the<object>
tag with all attributes as an HTML string (including the base64 advice above), then inject it into a DOM element withinnerHTML
,<object>
pointing back to the server.The later of these options is more intense, and requires round-trips from the server that you'd probably want to avoid - just some more options you might want to consider.
ActionScript 3 has a
Loader
which may be useful as well. I don't know if it supportsdata:
URI's, but if it does, you could write a boot loader SWF which runs the contents of the local swf file directly.