2
votes

So I’m trying to interact with a flash variables using jQuery. The original author of the flash based program has not got back to me yet and so I thought to ask here. I'm not that strong in AC3 so forgive me.

Within the original action script, I added a new import statement:

import flash.external.*;

There's a function that initializes the program called ini and added this towards the bottom:

//MODS=========== 
ExternalInterface.addCallback(‘gotoLastPage’,gotoLastPage) 
//===============

For all intensive purposes, just know that there is an existing and working function called gotoLastPage. It is declared as private void and works by the default application. All seemed fine there, got no errors when I recompiled the swf file.

Now the swf object is initialized like this

var flashvars = {}; 
flashvars.pages = “reader_fl/pages.xml”; 
flashvars.settings = “reader_fl/settings.xml”; 
var params = {}; 
params.quality = “high”; 
params.scale = “noscale”; 
params.wmode = “transparent”; var attributes = {}; 
attributes.align = “middle”; 
attributes.allowFullscreen = “true”;

swffit.showScrollV();
swfobject.embedSWF("reader_fl/PageFlip_v6.swf", "Reader_Window_player", "100%", "100%",
"10.0.0", false, flashvars, params, attributes);

As a note, I'm using swfobject. The reader comes up fine and is wrapping around a div called Reader_Window_player.

Now when I go to jQuery, I tried:

$("#Floating_CtrlStart").click(function(){
var Reader = $('#Reader_Window_player')[0];
Reader.gotoLastPage();
})

However, I still can’t seem to access the gotoLastPage. Console says that gotoLastPage is not defined.

Any help here?

2
try to add allowScriptAccess parameter , like: params.allowScriptAccess="always"Ivan Chernykh

2 Answers

0
votes

Are you opening the html page from the file system and not served from a web server? If so, that would explain why it's not working.

Calls to ExternalInterface fail if the content (html and swf) is in the local-with-networking or local-with-filesystem sandbox (source: http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7c9b.html).

-2
votes

I love JQuery but I usually do that the old fashion way:

var getSwf = function (swfName) {
   var isIE = navigator.appName.indexOf("Microsoft") != -1;
   return (isIE) ? window[swfName] : document[swfName];
}
getSwf("Reader_Window_player").gotoLastPage();

Also make sure you have the following in your JS:

attributes.id = "Reader_Window_player";
attributes.name = "Reader_Window_player";

and as @Cherniv stated in the comments:

params.allowScriptAccess="always"