I am trying to read the src attribute of the flash file which i get in the response of a url and create a new file through swfobject. But it returns me "undefined" when i read the src of the embed tag. My code below.
The page i am doing a post on, only has the flash file in it.
The reponse is as below:
AJAX REsponse
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="930" height="630" title="Campaign">
<param name="movie" value="final5.swf" />
<param name="quality" value="high" />
<embed src="final5.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="930" height="630"></embed>
</object>
Script
$.ajax({
url: flashUrl,
type: "POST",
dataType:"html",
success: function(data, status, xhr) {
var swfUrl = flashUrl.substr(0, flashUrl.lastIndexOf('/')) + "/" + $(data).find('embed').attr('src');
$('.content').html('<div id="mySwf"></div>');
swfobject.embedSWF(swfUrl, "mySwf", "200", "200", '9.0.0', "/resources/expressInstall.swf", flashvars, attributes, params);
}
});
***Update (found the issue area but not the solution)
I kinda got to know what the issue is, but i don't know y its occurring. when i run the page with the flash file in IE. it renderes it in a wierd way
<object width="930" height="630" title="Campaign" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" altHtml="
<embed src="skf-final5.swf" type="application/x-shockwave-flash" width="930" height="630" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" > </embed>
">
it add some altHTML attribute to the Object and the entire embed tag goes into it which screws up the entire stuff. :(
Well dint find the reason y we get a "altHTML" in the tag. but found a work around for this problem.
Heres my solution. (please suggest if there can be any improvements)
Note: FYI....The sequence of the properties in swfobject is also important. The Param has to come before the attribute or else it screws up some stuff in IE. :)