zondag 20 december 2015

HaXe / Stencyl : Javascript

== Javascript from haxe ==

code-block:

flash.external.ExternalInterface.call(“o3p_write(\”this is the text to store\”)”);


flash.html

<<html>
<head>
<script type="text/javascript">
   function hallo(){
   alert('hallo from swf');
   }
   function o3p_write(v){
   alert('Hi What is variable v : '+v)
   }
   
</script>
</head>
<center>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="480" HEIGHT="320" id="TileAPI" ALIGN="">
<PARAM NAME=movie VALUE="TileAPI.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#333399> <EMBED src="TileAPI.swf" quality=high bgcolor=#333399 WIDTH="480" HEIGHT="320" NAME="TileAPI" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED> </OBJECT>
</center>
</html>

Another:

ExternalInterface.call return values

To run javascript code inside a flash game you can use externalinterface.call.
The returnvalue is’nt always working.
This worked in Stencyl:



var theResult:String="";
#if flash
          theResult=ExternalInterface.call("doit_return");
trace("The result is: "+theResult);
#end


Javascript function:
function doit_return(){
   return "abcdef";

}

Geen opmerkingen:

Een reactie posten