GOOGLE推出SWIFFY插件 一键转换SWF到HTML5

刚刚看到的新闻如下:

谷歌刚刚发布Swiffy插件,可以将SWF转换为HTML,然后在手机上浏览(iOS,安卓等).Flash Pro 继续证明这是一种给作者创建桌面和移动内容的技术。不需要去学习一种新技术或工具去发布HTML。如果你熟悉Flash Pro,那么你所要做的就是安装Swiffy,发布一份你已经有的Flash文档内容到HTML。我肯定,我们将会看到越来越多的内置在Flash Pro顶部的技术,使用户能将swf发布到不同的格式。

下面是一张截图,显示了一个我在Flash Pro里为移动设备建立的现有的SWF,还有一份转换自SWF的Swiffy html。当然,现在还有一些局限性,但是我相信彻底地发布Flash Pro内容到HTML,只是时间问题。这些局限性是:
不支持多场景 (出现1次)
不支持Safari(移动端)滤镜(出现21次)
不支持混合模式(出现6次)
不支持位图缓存(出现1次)
不支持9切片缩放(出现10次)
不支持Actionscript 3.0(出现30次)
不支持音频流(出现139次)
不支持SWF10里推出的Open Type字体(出现2次)

我知道很多开发者和设计师从Flash运行时角度考虑,而Swiffy是仅针对该平台的创作工具。实际上,这是不断变化的,我们将把Flash Pro看做不同格式内容的创作工具。Swiffy只是证明这个的一种途径。我肯定,我们会看到更多的内建于Flash上的更多其他的扩展,导出swf内容到不同的格式。
Flash Pro用户的优势在于,没有学习阻碍。成千上万的开发者和设计师们知道这个工具,并且非常熟悉它。你所需要做的,就是安装Swiffy 并发布为HTML,就这么简单。
你必须爱Flash Pro!!

于是我找到这个swiffy插件安装~

之后在Flash Pro CS5.5中制作了简易的从左到右的图片补间动画

之后选择 命令->Export as HTML5(swiffy)输出

若文档中包含AS3代码,则输出HTML5的时候会出现错误提示

即 多场景 及 AS3 不被支持

输出后的HTML代码为

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Swiffy output</title>
<script src="http://www.gstatic.com/swiffy/v3.6/runtime.js"></script>
<script>
swiffyobject = {"tags":[{"id":1,"height":399,"width":600,"data":"data:image/jpeg;base64,/图像编码(略)//Z","type":8},{"bounds":[{"ymin":-1250,"ymax":1250,"xmin":-1879,"xmax":1880}],"id":2,"paths":[{"fill":1,"data":["mhvhv:80r50L759C00y759c00Y"]}],"fillstyles":[{"transform":"000s::000s::","bitmap":65535,"type":8},{"transform":"265e::265e79R50L","bitmap":1,"type":8}],"type":1},{"id":2,"matrix":"::::79u40n","type":3,"depth":1},{"type":2},{"matrix":"::::24y40n","type":3,"depth":1},{"type":2},{"matrix":"::::870b40n","type":3,"depth":1},{"type":2},{"matrix":"::::215c40n","type":3,"depth":1},{"type":2},{"matrix":"::::560c40n","type":3,"depth":1},{"type":2},{"matrix":"::::905c40n","type":3,"depth":1},{"type":2},{"matrix":"::::250d40n","type":3,"depth":1},{"type":2},{"matrix":"::::596d40n","type":3,"depth":1},{"type":2},{"matrix":"::::941d40n","type":3,"depth":1},{"type":2},{"matrix":"::::286e40n","type":3,"depth":1},{"type":2},{"matrix":"::::631e40n","type":3,"depth":1},{"type":2},{"matrix":"::::976e40n","type":3,"depth":1},{"type":2},{"matrix":"::::322f40n","type":3,"depth":1},{"type":2},{"matrix":"::::667f40n","type":3,"depth":1},{"type":2},{"matrix":"::::012g40n","type":3,"depth":1},{"type":2},{"matrix":"::::357g40n","type":3,"depth":1},{"type":2},{"matrix":"::::702g40n","type":3,"depth":1},{"type":2},{"matrix":"::::048h40n","type":3,"depth":1},{"type":2},{"matrix":"::::393h40n","type":3,"depth":1},{"type":2},{"matrix":"::::738h40n","type":3,"depth":1},{"type":2},{"matrix":"::::410h40n","type":3,"depth":1},{"type":2},{"matrix":"::::082h40n","type":3,"depth":1},{"type":2},{"matrix":"::::754g40n","type":3,"depth":1},{"type":2},{"matrix":"::::426g40n","type":3,"depth":1},{"type":2},{"matrix":"::::098g40n","type":3,"depth":1},{"type":2},{"matrix":"::::770f40n","type":3,"depth":1},{"type":2},{"matrix":"::::442f40n","type":3,"depth":1},{"type":2},{"matrix":"::::114f40n","type":3,"depth":1},{"type":2},{"matrix":"::::787e40n","type":3,"depth":1},{"type":2},{"matrix":"::::458e40n","type":3,"depth":1},{"type":2},{"matrix":"::::131e40n","type":3,"depth":1},{"type":2},{"matrix":"::::803d40n","type":3,"depth":1},{"type":2},{"matrix":"::::475d40n","type":3,"depth":1},{"type":2},{"matrix":"::::147d40n","type":3,"depth":1},{"type":2},{"matrix":"::::819c40n","type":3,"depth":1},{"type":2},{"matrix":"::::491c40n","type":3,"depth":1},{"type":2},{"matrix":"::::163c40n","type":3,"depth":1},{"type":2},{"matrix":"::::835b40n","type":3,"depth":1},{"type":2},{"matrix":"::::07y40n","type":3,"depth":1},{"type":2},{"matrix":"::::79u40n","type":3,"depth":1},{"type":2}],"v":"3.6.1","backgroundColor":16777215,"frameSize":{"ymin":0,"ymax":3000,"xmin":0,"xmax":11000},"frameCount":40,"frameRate":24,"version":11};
</script>
</head>
<body style="overflow:hidden;margin:0;">

<script>var stage = new swiffy.Stage(document.body, swiffyobject);</script>
<script>stage.start();</script>

</body>
</html>

通过观察,其并不是把swf 转换到 成javascript然后调用html5里面的canvas标签进行重绘。而是调用到插件官方的 “http://www.gstatic.com/swiffy/v3.6/runtime.js” 运行时进行运算。即本地把swf的补间动画的各个属性(坐标,大小,位移)传递给运行时,运行时把绘制结果发送过来罢了。

除了文章中的提到的 多场景+AS3不支持外。 fla是中文名 也是无法输出的。

令我诧异的是,swf中包含一张图片,这张图片并没有上传到官方,也没有放置在html同目录下。但是输出的html文件仍然显示了该图片。 研究了下输出的html的代码,发现它是把整张图片的编码都一起放置到输出的html文件中了。 那么如果你的swf中包含多张图片。那么输出的html5文件估计会非常大,因为图片不是外部加载进来的,而是直接“嵌入”到html文件中的。

swiffy目前这个插件还是 beta阶段。期待它完善。目前Adobe的技术人员也在致力于将AS3转换成JS的研究了。相信很快就会有比较成熟的解决方案出来了。

输出后的demo演示地址如下:
http://www.aoicon.in/demo/swiffy/snv.swf.html

QQ大乐透招式动画HTML5演示:
http://www.aoicon.in/demo/swiffy/qq.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.