将 Flash 文件转换为 HTML
Converting Flash File to HTML
我有 flash 文件 (.fla),使用 Adobe Animate 将其转换为 HTML。转换时很少有代码被注释掉。需要确定 java 脚本等价于 syntax/piece 注释 Actionscript 的代码。以下是示例注释操作脚本。
dashboard_btn.onRelease = function() {
ExternalInterface.call("Main.getInstance().FlashDecision","DASHBOARD");
gotoAndStop("DASHBOARD");
}
如何替换onRelease和ExternalInterface.call?
例如,gotoAndStop("DASHBOARD"); //ActionScript,可以转换为this.gotoAndStop("DASHBOARD"); //Javascript
"How to replace onRelease
and ExternalInterface.call?
"
(1) 对于 onRelease
你可以使用 HTML 的 mouseup 事件:
所以 AS3 代码:
dashboard_btn.onRelease = function()
在 Javascript 中它变成了...
(其中 div 是 容器 ,类似于 Flash 的 MovieClip/Sprite 容器:
<div id="dashboard_btn" onmouseup="someFunctionName();">
<img src="img_of_button.png" width="80" height="30">
</div>
<script type="text/javascript">
function someFunctionName()
{
//do what need when user's finger leaves a mouse button (release)
alert("finger was released from button");
}
</script>
(2) HTML代码中没有ExternalInterface.call
。这是为了让 SWF 与其容器通信(例如:如果 SWF 包含在 HTML 文档中,则调用 Javascript 的函数)。如果您要转换为 Javascript,那么您的代码已经 在容器内 (此时不需要 externalInterface
存在)。只需在需要时手动调用 Javascript 函数即可。
如果你的代码 确实 包含一些名为 gotoAndStop
的 JS 函数,那么使用它,否则你可以通过显示 "DASHBOARD" 的内容来手动实现相同的目的框架。内容可以通过创建一些 HTML 字符串然后使用 appendChild
或 innerHTML
更新 <div>
容器来提供 HTML.
你可以将上面的代码扩展成这样的逻辑:
function someFunctionName()
{
//# do what need when user's finger leaves a mouse button (release)
alert("finger was released from button");
//# if such Function exists in your code
this.gotoAndStop("DASHBOARD");
//# or else run some other Function manually
FlashDecision("DASHBOARD");
}
function FlashDecision( input_txt )
{
alert("Show content here of frame labeled : " + input_txt); //where input_txt is "DASHBOARD"...
}
我有 flash 文件 (.fla),使用 Adobe Animate 将其转换为 HTML。转换时很少有代码被注释掉。需要确定 java 脚本等价于 syntax/piece 注释 Actionscript 的代码。以下是示例注释操作脚本。
dashboard_btn.onRelease = function() {
ExternalInterface.call("Main.getInstance().FlashDecision","DASHBOARD");
gotoAndStop("DASHBOARD");
}
如何替换onRelease和ExternalInterface.call?
例如,gotoAndStop("DASHBOARD"); //ActionScript,可以转换为this.gotoAndStop("DASHBOARD"); //Javascript
"How to replace
onRelease
andExternalInterface.call?
"
(1) 对于 onRelease
你可以使用 HTML 的 mouseup 事件:
所以 AS3 代码:
dashboard_btn.onRelease = function()
在 Javascript 中它变成了...
(其中 div 是 容器 ,类似于 Flash 的 MovieClip/Sprite 容器:
<div id="dashboard_btn" onmouseup="someFunctionName();">
<img src="img_of_button.png" width="80" height="30">
</div>
<script type="text/javascript">
function someFunctionName()
{
//do what need when user's finger leaves a mouse button (release)
alert("finger was released from button");
}
</script>
(2) HTML代码中没有ExternalInterface.call
。这是为了让 SWF 与其容器通信(例如:如果 SWF 包含在 HTML 文档中,则调用 Javascript 的函数)。如果您要转换为 Javascript,那么您的代码已经 在容器内 (此时不需要 externalInterface
存在)。只需在需要时手动调用 Javascript 函数即可。
如果你的代码 确实 包含一些名为 gotoAndStop
的 JS 函数,那么使用它,否则你可以通过显示 "DASHBOARD" 的内容来手动实现相同的目的框架。内容可以通过创建一些 HTML 字符串然后使用 appendChild
或 innerHTML
更新 <div>
容器来提供 HTML.
你可以将上面的代码扩展成这样的逻辑:
function someFunctionName()
{
//# do what need when user's finger leaves a mouse button (release)
alert("finger was released from button");
//# if such Function exists in your code
this.gotoAndStop("DASHBOARD");
//# or else run some other Function manually
FlashDecision("DASHBOARD");
}
function FlashDecision( input_txt )
{
alert("Show content here of frame labeled : " + input_txt); //where input_txt is "DASHBOARD"...
}