I have flash file(.fla), using Adobe Animate converted the same to HTML. Few code has been commented out while conversion. Need to identify java script equivalent syntax/piece of code for commented Actionscript. Following is the sample commented action script.
dashboard_btn.onRelease = function() {
ExternalInterface.call("Main.getInstance().FlashDecision","DASHBOARD");
gotoAndStop("DASHBOARD");
}
How to replace onRelease and ExternalInterface.call?
For Example, gotoAndStop("DASHBOARD"); //ActionScript, can be converted to this.gotoAndStop("DASHBOARD"); //Javascript
"How to replace
onRelease
andExternalInterface.call?
"
(1) For onRelease
you can use HTML's mouseup event:
So the AS3 code:
dashboard_btn.onRelease = function()
In Javascript it becomes something like...
(where div is the container, similar to Flash's MovieClip/Sprite containers):
<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) There is no ExternalInterface.call
in HTML code. That is for the SWF to communicate with its container (eg: calling a function of Javascript if SWF is contained inside an HTML document). IF you're converting to Javascript then your code is already inside the container (no need for externalInterface
to exist at this point). Just manually call the Javascript function when needed.
If your code truly contains some JS function called gotoAndStop
then use it, or else you could manually achieve same thing by showing content of "DASHBOARD" frame. The content could be provided by creating some HTML string and then using appendChild
or innerHTML
to update a <div>
container with that HTML.
You could extended the above code into logic like this:
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"...
}