Search code examples
javascriptactionscript-3externalinterface

ExternalInterface to call a function belongs to a JS object


I'm using ExternalInterface in my AS3 project to do some stuff via Javascript, but now I need to use it to call some function belong to an object.

Something like this (AS3):

ExternalInterface.call("VIEWER.loadComplete");

JS code:

var VIEWER = {
    loadComplete: function(){
        $('#'+this.maindiv).children('.mask').hide();
        $('#'+this.viewer).css({
            width:      '640px', 
            height:     '480px',
            overflow:   ''
        });
    }
}

This isn't working in Chrome (only works in Firefox, and I don't know why either). Can someone clarify me in this way?


Solution

  • I solved my own problem adding the following to my SWF object embed in HTML:

    <param name="AllowScriptAccess" value="always">
    

    Now my SWF is able to call ExternalInterface (even in Chrome).