The FDMSLib for the Flex-AJAX bridge has a load function that renders a flash object to the page where ever it is called. This causes problems when using Ext.JS as the inserted object can either be discarded by another render function or cause conflicts during the rendering of the page, so I'm trying to rewrite the load function so that its Ext.JS (and probably other JS framework) friendly.
This is the original function.
FDMSLibrary.load = function(path, callback)
{
var result = "<object id='_fesLib' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' \
codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,5,0,0' \
height='1' width='1'> \
<param name='flashvars' value='bridgeName=flash'/> \
<param name='AllowScriptAccess' value='always'/> \
<param name='src' value='"+ (path != undefined ? path : "") + "'/> \
<param name='wmode' value='transparent' /> \
<embed name='_fesLib' pluginspage='http://www.macromedia.com/go/getflashplayer' allowScriptAccess='always'\
src='" + (path != undefined ? path : "") + "' height='1' width='1' flashvars='bridgeName=flash'/> \
</object>";
document.write(result);
// todo:need a callback and variable here so you can keep track that both the fabridge and the fdmsbridge are available
FDMSLibrary.addInitializationCallback("flash", callback);
// register for call back when the FABridge has completed initialization
FABridge.addInitializationCallback("flash", FABridge_ready);
}
I've replaced this with the following :
loadFDMSBridge: function(path,callback) {
var FABridgeSWF = new Ext.FlashComponent({
id : '_fesLib',
height: '1',
width: '1',
flashVars : {
bridgeName:'flash'
},
wmode : 'transparent',
flashVersion : '8.5.0.0',
renderTo : Ext.getBody(),
url : path,
listeners : {
'render' : {
fn : this.initBridge,
scope : this
}
}
});
},
initBridge : function () {
FDMSLibrary.addInitializationCallback("flash", this.initPolling);
FABridge.addInitializationCallback("flash", FABridge_ready);
}
The flash object is rendered to the page, it uses the data attribute in object rather than a src param, but I assume this is correct for rendering flash objects.
The problem I'm having with this is that when I call the FDMSLibrary.addInitializationCallback function it would appear that the bridge is not ready.
The javascript is told by the swf file that it is ready to be used. I'm pretty certain that its no a problem with the swf as I have an simple test page up and running using the same swf and javascript libraries, but without any interference from any other javascript, content and so on. It kind of feels like the swf isn't being loaded and "executed" and Firebug would seem to back this up, but I don't really know why or what I've missed.
If you would like to see the full javascript libraries and the actionscript source for the FABridge you can find them here in Adobe's subversion repo : fds ajax bridge repo path
Thanks in advance for your help