I am trying to call call action script function from JS but i get the following error
Error: getFlashMovie(swfobjectID).sayWhat is not a function
You might need an other kind of workaround in js to call the flash function from any browser.
Here i share my way to accomplish this (hope it is not deprecated yet...). You need a javascript class (i named it FO):
/**
*
* @param id
* @param swf
* @param width
* @param height
* @param scriptAccess
* @param allowFullscreen
* @return
*/
function FO(id, swf, width, height, scriptAccess, allowFullscreen){
this.id = id;
this.movie = swf;
this.height = height ? height : 180;
this.width = width ? width : 240;
this.scriptAccess = scriptAccess ? scriptAccess : "always";
this.allowFullscr = allowFullscreen ? "true" : "false";
this.obj = document.createElement("embed");
this.obj.src = this.movie;
this.obj.width = this.width;
this.obj.height = this.height;
this.obj.name = this.id;
this.obj.id = this.id;
this.obj.align = "middle";
this.obj.type = "application/x-shockwave-flash";
this.obj.setAttribute("quality", "high");
this.obj.setAttribute("bgColor", "#bee3f6");
this.obj.setAttribute("play", "true");
this.obj.setAttribute("loop", "false");
this.obj.setAttribute("allowScriptAccess", this.scriptAccess);
this.obj.setAttribute("allowFullscreen", this.allowFullscr);
this.obj.setAttribute("pluginspage", "http://www.adobe.com/go/getflashplayer");
}
FO.prototype = {
id :null,
width :null,
height :null,
movie :null,
scriptAccess :null,
allowFullscr :null,
obj :null,
addParam : function(name, value){
var p = document.createElement("param");
p.name = name;
p.value = value;
this.obj.appendChild(p);
}
};
You will need an initialization method (or extend the existing one):
// should be called on window.onload
function init() {
var flashObject = null;
if (isIE)
flashObject = document.getElementById("myMovieName");
else
{
flashObject = new FO("myMovieName", "ax.swf", 225, 200).obj;
// **app** is the id of a div / html container element,
// in which your
and for calling the desired method:
//somewhere else in your code:
if (flashObject)
flashObject.sayWhat();