Very recently I was debugging a piece of javascript with my colleague. I thought that the javascript didn’t look very clean, though it was copied from a reputed website. The javascript was basically meant for handling the fscommand event from a Flash movie and perform some actions.
The code to do this consisted of javascript as well as VBScript code, and involved document.write() which I found a bit odd. I thought that there had to be a cleaner way of doing things and soon found out this neat jscript code to accomplish the same. Let me tell you I am not an expert on Flash and the following code will work only with IE. Given below is an example flash movie and it’s actionscript code that calls the ‘fscommand()’ on mouse click and passed the coordinates of the point as parameters.
Click anywhere on the above flash movie
class Main |
First we write a javascript function that we want to call on the fscommand. Then we write the code that links this function to the fscommand.
<object id="testflash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" |
<script language="javascript"> |
<script FOR="testflash" EVENT="FSCommand" LANGUAGE="Jscript"> |
It is worth nothing here that the script is mixture of javascript and jscript. But at least it doesn’t contain document.write().