Flash JavaScript Integration Kit causes the unexpected page refreshes

Posted on 2005-9-1 星期四

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”:

  1. FlashProxy.callJS = function()
  2. {
  3.     var functionToCall = eval(arguments[0]);
  4.     var argArray = new Array();
  5.     for (var i = 1; i < arguments.length; ++i)
  6.     {
  7.         argArray.push(arguments[i]);
  8.     }
  9.     functionToCall.apply(functionToCall, argArray);
  10. }

To solve this problem I’v used the usual way to invoke javascript function:

  1. var InternetExplorer = navigator.appName.indexOf(“Microsoft”) != -1;
  2. function fplayer_DoFSCommand(command, args){
  3.         var fplayerObj = InternetExplorer ? fplayer : document.fplayer;
  4.         switch (command) {
  5.                 case “function_name1″ :
  6.                 function_name1();
  7.                 break;
  8.                 case “function_name2″ :
  9.                 function_name2();
  10.                 break;
  11.                 …     
  12. }
  13. }
  14. if (navigator.appName && navigator.appName.indexOf(“Microsoft”) != -1 &&
  15.   navigator.userAgent.indexOf(“Windows”) != -1 && navigator.userAgent.indexOf(“Windows 3.1″) == -1) {
  16.   document.write(‘<SCRIPT LANGUAGE=VBScript\> \n);
  17.   document.write(‘on error resume next \n);
  18.   document.write(‘Sub fplayer_FSCommand(ByVal command, ByVal args)\n);
  19.   document.write(‘ call fplayer_DoFSCommand(command, args)\n);
  20.   document.write(‘end sub\n);
  21.   document.write(‘</SCRIPT\> \n);
  22. }
  23.  
  24. //functions
  25. function function_name1(){
  26. blabla…
  27. }
  28. function function_name2(){
  29. blabla…
  30. }

In the flash we should invoke javascript function like this :

  1. function vfull(){
  2.         fscommand (“function_name1″, parameter1);
  3.         }

No comments have been added to this post yet.

留下评论

(必需)

(必需)


Information for comment users
Line and paragraph breaks are implemented automatically. Your e-mail address is never displayed. Please consider what you're posting.

Use the buttons below to customise your comment.


RSS feed for comments on this post | TrackBack URI