Question

I have a flash that communicates with a javascript using ExternalInterface. I have converted this into HTML5 using swiffy. How do call the methods i have created in flash using javascript?

Was it helpful?

Solution 2

As per the swiffy documentation, ExternalInterface is not supported for AS 2.0 or AS 3.0 by swiffy.

Please refer to:

OTHER TIPS

Here is an update to the answer for who is still looking: As of now, Swiffy 5.3 has already supported ExternalInterface. I am able to make javascript call from AS3 using:

ExternalInterface.call("jsFunction", args);

In js, you just need to declare the "jsFunction" :

<script>
    function jsFunction(args) {
       alert("Call from AS3");
    }
</script>

For the reverse direction, calling from JS to AS3 through Swiffy can be achieved using this in AS3:

ExternalInterface.addCallback("nameForJS", closeFunction);
function closeFunction(s:String) {
    trace("Received " + s + " from js");
}

In JS, you will need to get the DOM el that tight to swiffy, and execute the function from there:

document.getElementById("swiffycontainer").nameForJS();

Hope this helps!

Still, it is easy to call JavaScript function from AS3-to-HTML5-via-Swiffy :

var urlRequest : URLRequest = new URLRequest( "javascript:doRoo();" );
navigateToURL( urlRequest,'_self' );

What is the best way to call a function that was declared in AS3 pre-swiffy from JavaScript - basically the reverse?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top