When I use Flash JavaScript Integration Kit to develop flash javascipt collaborative application,I found that when calls function from Flash to JavaScript will cause the web page refreshment,this will reset the statement of the page ,for example the windows media player will be reset and play from beginning. The reason is “called implicitly” in the “FlashProxy.js”:
-
FlashProxy.callJS = function()
-
{
-
var functionToCall = eval(arguments[0]);
-
var argArray = new Array();
-
for (var i = 1; i < arguments.length; ++i)
-
{
-
argArray.push(arguments[i]);
-
}
-
functionToCall.apply(functionToCall, argArray);
-
}
To solve this problem I’v used the usual way to invoke javascript function:
-
var InternetExplorer = navigator.appName.indexOf(“Microsoft”) != -1;
-
function fplayer_DoFSCommand(command, args){
-
var fplayerObj = InternetExplorer ? fplayer : document.fplayer;
-
switch (command) {
-
case “function_name1″ :
-
function_name1();
-
break;
-
case “function_name2″ :
-
function_name2();
-
break;
-
…
-
}
-
}
-
if (navigator.appName && navigator.appName.indexOf(“Microsoft”) != -1 &&
-
navigator.userAgent.indexOf(“Windows”) != -1 && navigator.userAgent.indexOf(“Windows 3.1″) == -1) {
-
document.write(‘<SCRIPT LANGUAGE=VBScript\> \n‘);
-
document.write(‘on error resume next \n‘);
-
document.write(‘Sub fplayer_FSCommand(ByVal command, ByVal args)\n‘);
-
document.write(‘ call fplayer_DoFSCommand(command, args)\n‘);
-
document.write(‘end sub\n‘);
-
document.write(‘</SCRIPT\> \n‘);
-
}
-
-
//functions
-
function function_name1(){
-
blabla…
-
}
-
function function_name2(){
-
blabla…
-
}
In the flash we should invoke javascript function like this :
-
function vfull(){
-
fscommand (“function_name1″, parameter1);
-
}