I've tried multiple ways to edit Flash Objects / Embeds via Javascript and it seems to work in everything but IE, so I'm thinking about just throwing IE out the window for this application unless there are older + used version of other browsers that also do not allow you to edit objects. An example of this would be:
document.getElementById(divID).innerHTML = '<object ...><embed ...><\/embed><\/object>';
or in jquery
var params = '<param name="allowFullScreen" value="true" />' +
'<param name="allowScriptAccess" value="always" />' +
'<param name="allowNetworking" value="all" />' +
'<param name="movie" value="player.swf" />' +
$("#objectPlayer").html(params);
If all the rest of the modern browsers and the most used versions of them do support this kind of editing then I'll just scrap IE. And before I get floods of the SWFObject JS Framework, I'm not going to include a huge framework for a browser that I do not believe is going to contain my demographic.
JSFiddle
Here's a link to a JSFiddle I created. It works in all browsers but IE8
If i understand your question and purpose of usage, this is what I would suggest.
I would make use of SWFObject for embedding your SWF onto your HTML page. From there on you can pass flashVars (Object where you can set custom values on) to your SWF. It's not much effort to implement this and it's cleaner in usage (in my opinion). The values of the flashVars can easily be set with PHP values or fill them with plain values.
Have a look at this article for more information about SWFObject and FlashVars and how to use them in ActionScript 3.
Hmmm... strange, the DOM wouldn't update properly in IE8. This is working code. It is ugly and there is plenty of room for optimisation:
JS:
JSFiddle is here
I believe the
<param>
part of your code is for<object>
.You have to pass the name/value pairs for
embed
too.But I would use SWFObject anyway, it is the industry standard, it's quite robust and it is the best way of embedding flash on the website.
You can try something like this...
http://jsfiddle.net/eH8cK/
You can actually rewrite the entire contents of the player when you are already rewriting almost most of the contents.
Please try and let me know if it works. Thanks
The only decent alternative to SWFObject that I'm aware of is the jQuery Tools Flashembed plugin which is 3.6k minified (and less when served with compression):
http://jquerytools.org/demos/toolbox/flashembed/index.html
Download link: http://jquerytools.org/download/ The only dependency is jQuery itself.
I had this really weird bug with IE8 in one of my projects, that was very hard to catch - it made Google's excanvas fail if the canvas elements were added using the
innerHTML
instead of using thedocument.createElement
/document.appendChild
.I fixed it by taking all the
canvas
elements that were created using theinnerHTML
, and reacreated them using the DOM'screateElement
method.I've noticed similar issues with other 'interactive' elements in IE8, so I'd suggest you try this.
I have no IE8 to test it, but here, try it on jsfiddle