Changes to the Flash / JavaScript Integration Kit

Over the last couple of days, we’ve made several changes to the Flash / JavaScript Integration Kit. If you are using the Integration Kit, or if you’re interested in using it, I strongly recommend grabbing the latest code out of Subversion.

Here is a list of the changes we’ve been working on:

  1. The Integration Kit now uses FSCommand to go from Flash to JavaScript on Internet Explorer on Windows. Using getURL causes several issues on IE, and we found that FSCommand works much better in that environment. You will no longer get that odd clicking sound that IE likes to make when you click on a link, and the kit will no longer cause open sockets (images in the process of loading, XMLHttpRequest sockets, etc) to be prematurely closed.
  2. We added the ability to handle multiple consecutive calls from JavaScript to Flash. Before, if you tried to make multiple consecutive calls, typically just the last one would succeed. Now, not only can you make as many calls as you want, but all the calls are guaranteed to happen in the correct order. (Basically we added a queuing mechanism to the JavaScript.)
  3. We added an optional scope argument to the FlashProxy. This allows you to specify the JavaScript scope (object instance) that you want to call functions on from Flash. This argument is entirely optional, and leaving it out will result in the kit working just as it did before (calling functions within the document scope).
  4. We fixed a bug that was breaking function calls from Flash to JavaScript when passing strings with single quotes in them.
  5. We added support for Opera 8.0 and higher (at least that’s what we tested on — it might work with earlier versions) on both Mac and Windows.

There is one additional issue with respect to getURL and FSCommand I need to explain. If your Flash content is compiled for Flash Player 7 or higher, the Integration Kit will automatically use FSCommand where appropriate and getURL everywhere else. This is definitely the recommend usage. If your content is compiled for Flash Player 6, getURL will be used universally. That doesn’t mean it won’t work in IE on Windows, but it doesn’t work nearly as smoothly as FSCommand. The bottom line is that if you can compile for Flash Player 7 (which now has more than 90% penetration), you should do so.

We have not done another official release of the Integration Kit with all these changes yet. Right now, the official release is pretty old code with lots of issues, so we definitely recommend using the newest code from Subversion. We hope to do another official release of both the code and documentation very soon (maybe next week).

Let me know if you discover any issues so we can get them fixed before the next official release.

13 Responses to Changes to the Flash / JavaScript Integration Kit

  1. felix says:

    Does the Flash / JavaScript Integration Kit work with the Flash 8 player?thanks!

  2. Dennis says:

    Wow what a great set of code!—Ok, not sure anyone has run into this one and can not find an answer a week after finding the problem.I am creating an online advertistement that calls a javascript function on the page to rewrite a DIVs content. Basically turning a floating ad into a static version after X amount of seconds.When the HTML page and SWF reside on the same domain it can call the function just fine…ex: getURL(“javascript: functionCall();”);But when the SWF is on another domain and I load it onto the HTML page using the same exact code the function never seems to get called. What is the issue here? Is it a security problem I never come across? Do I need to reference something from the SWF so it calls the javascript I’ve included on the HTML page?This one is stumping me!

  3. Felix, yes it does, but you might also want to check out the new external interface API:

  4. MdiX says:

    Hi, thanks for this code. It is really interesting to see how you set this all up. I’m using it to build a flash based CMS.I ran into a small problem getting the newest version to work and that is that I seemed to have the callbackscope, but I had no idea how to set this up, so I commented out the code that uses it inside FlashProxy.callJS.One other thing worth mentioning is that I tried to send Flash objects (result objects from remoting) to Javascript, but I needed to change the result with all properties into an array with indexes (this was done inside my own .as file). Now it works great.Thanks a lot for this code!

  5. voltron says:

    Hi Mr. Cantrell!is there a chance that the new version would be merged with the normal download? I dont have a Subversion client.Thanks

  6. Rob McKeown says:

    You mention that compiling for player 7 is preferred. Does that mean that both the JavaScriptFlashGateway.fla and my application both need to be compiled for 7?Thanks

  7. Mike says:

    I am glad to see you added support for Opera 8.0 and fixed that nasty bug. And thanks for posting the new codes!!

  8. Thanks for the link to the newest code was wondering if I was ever going to be able to find it.

  9. Soule says:

    It seems that JavaScript to Flash communication is broken in Opera 8.51. I’ve been using the kit to integrate the browser back button with success on the latest browsers (IE, FF, NS), except for Opera. On Opera 8.51 communication works from Flash to JavaScript, but not the reverse.

  10. Matthew says:

    Be sure to check this in FF as there is a javascript error in FlashProxy.callJS. Something about “argsArray.shift()” not being a function. I think this occurs when number of arguments is 0.If I am able to fix this, where can I submit a patch?

  11. Pieter Soudan says:

    You say the bug for opera 8+ was fixed with the new version. I still encounter problems using the JSFlashGateway in opera 8.51.The first time the flash is loaded, all communication between the flash and javascript works just fine. As soon as the flash is loaded from cache, I can’t call any Flash-functions from Javascript. Cached version works fin on any other browser i tried…

  12. Notebooki says:

    I am also using Opera of 8.51 and mums the same problems like you Peter, I wouldn’t like to give up for it and to go on IE. I am thinking whether in placing the Opera of something can I didn’t include or I didn’t charge some plug-in.