Potato.Head 0 Light Poster

Hi to all,
I have the following problem:
1. I have a page where I insert flash objects dynamically.
2. Every flash receive a id and name dynamically
3. I need to insert JavaScript handlers for the flash.
The following code is working just fine:

<SCRIPT>
function swfObject_DoFSCommand()
{
    alert("a");
}
</SCRIPT>
<SCRIPT event="FSCommand(command,args)" for="swfObject">swfObject_DoFSCommand(command,args);</SCRIPT>
<div id="DivScript"></div>
<OBJECT id="swfObject" name="swfObject" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>
<PARAM NAME="Movie" VALUE="MyMovie.swf">
<PARAM NAME="src" VALUE="MyMovie.swf">
<PARAM NAME="WMode" VALUE="Transparent">
<PARAM NAME="Play" VALUE="true">
</OBJECT>

This code is not working:

I call to the method 'AddScript'

<script>
function AddScript()
{
var element = document.createElement("script");
element.setAttribute("for","swfObject");	
element.setAttribute("event","FSCommand(command,args)");
element.text = "swfObject_DoFSCommand(command,args);";
//append the script to the container.	
var container = document.getElementById("DivScript");
container.appendChild(element);	
}
</script>

I see with the developer tool in IE8, that the code is added just fine, but the code is not working, the flash doesn't call to the method.

Any ideas?
Thanks