I'm still attempting to get SWFObject to play nice with an ajax div load, it loads the content and plays the flash fine without SWFObject and I know its not initializing the SWFObject javascript. Through a couple places I've been shown how I can get it to intialize but for the life me dont see what the swfobject trigger for onload is. I can see attachevents for unloading of the SWF to fix a bug but nothing regarding that specifically.
Any help with this would be great, I just need it to play nice with this and feel I'm quite close and this could help others I've seen with similar issues if I can get it to work. Designer, trying to but on his developer hat.. but much happier playing with pixels.
I was supplied with the ajax script which came from Dynamic Drive, if someone else has a better solution I'd love to here it. The project requires dynamic loading of flash video content within a page, with multiple video links per page, as well as the ability to have flash detection and degrade to allow use of the site.
SWFObject has worked great for me in the past, and is working well in other parts of the site, but the ajax isnt intializing the javascript. I found solutions that run a routine to check if content was loaded into the div and call a function. However that seems to have limited success anyway, and I'm not sure exactly what should go as the onload function that the if/else routine should call.
Any help would be awesome, or else I'll probably have to reload the pages with a URL string for the videos, which will piss the client off.. hehe.
Ok. I understand a bit better what you are wanting to do.
I had to write a similar thing for a demo page a while ago. The user filled in some options in a form and we had to generate flash content on the fly without refresh. Here is the basic skeletal structure: . . . // make standard AJAX call and set handler function // the xml var was an xml structure I was passing up to the server from the createXML() method
var xml = createXML(); var url = "http://some.com/someservlet?timeStamp=" + new Date().getTime(); xmlHttp.open("POST", url, true); xmlHttp.onreadystatechange = handleStateChange; xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;"); xmlHttp.send(xml);
// handle Ajax results
function handleStateChange() { if ( xmlHttp.readyState == 4 ) { if ( xmlHttp.status == 200 ) { // we have a ready status, so show the flash content parseResults(); } else { alert ("ERROR ! - HTTP Status code : " + xmlHttp.status); } } }
// we have a standard preloader, and only change the actual content to be loaded / shown // with our Ajax result from the server // e.g. of result http://some.server.com/some/dir/some.swf
function parseResults() { var so = new SWFObject("preloader.swf", "vid", "320", "240", "7", "#ffffff"); so.addVariable("contenturl", xmlHttp.responseText); so.setAttribute('scale', 'exactfit'); so.setAttribute('align', 'top'); so.write("flashcontent"); }
. . . // standard div with status text until we replace with flash
Click 'Render' to submit.
I hope this makes sense / is what you're after etc. Let me know if anything is unclear