Forum Moderators: open

Message Too Old, No Replies

Append Flash Movie in a layer

         

ShawnJC

12:26 am on Mar 4, 2004 (gmt 0)

10+ Year Member



Hello, I seem to be having a little trouble nailing down the correct way to create a flash object and append it to the document when it loads. I'm not sure the right way to put the <param> tags inside the <object> tag as well as the <embed> tag. I'm getting errors on this in IE, so if anyone has some insight it would be greatly appreciated:

function createFlashLayer2 (name,flashID,swf,xpos, ypos) {

var layer = document.createElement ('div')
var tobject = document.createElement('object')
var param1 = document.createElement('param')
var param2 = document.createElement('param')
var param3 = document.createElement('param')
var tembed = document.createElement('embed');

layer.setAttribute ('id', name);
layer.setAttribute ('style', 'position:absolute; left:'+xpos+';top:'+ypos);

tobject.setAttribute('classid','clsid:27CDB6E-AE6D-11cf-96B8-444553540000');
tobject.setAttribute('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0');
tobject.setAttribute ('id', flashID);

param1.setAttribute('movie',swf);
param2.setAttribute('quality','high');
param3.setAttribute('wmode','transparent');

tembed.setAttribute('src',swf);
tembed.setAttribute('width','350');
tembed.setAttribute('height','300');
tembed.setAttribute('quality','high');
tembed.setAttribute('pluginspage','http://www.macromedia.com/go/getflashplayer/');
tembed.setAttribute('type','application/x-shockwave-flash');
tembed.setAttribute('wmode','transparent');
tembed.setAttribute ('name', flashID);
onload = function ()
{
document.body.appendChild (layer);
document.getElementById(name).appendChild(tobject);
document.getElementById(flashID).appendChild(param1);
document.getElementById(flashID).appendChild(param2);
document.getElementById(flashID).appendChild(param3);
document.getElementById(flashID).appendChild(tembed);
}

ShawnJC

8:11 pm on Mar 4, 2004 (gmt 0)

10+ Year Member



Ok, well I did it....I don't know how but I did it. I even read an article on the net by some Javascript Professor that said it wasn't possible. I'll see if I can post more detailed information once I figure out really what it is that I did ha ha. The main thing is that IE will not access the object tag with embed appended to it....IE needs to create a flash object with the embed tag! Now, how do you go about putting the params for wmode/transparent and naming the thing.....Well, here's what I got. It works and it really shouldn't:

Obj = document.createElement("embed","wmode");
Obj.setAttribute("src",swf);
Obj.setAttribute("width",250);
Obj.setAttribute("height",300);
Obj.setAttribute("wmode", "transparent");
Obj.setAttribute ("id",flashID);
layer.appendChild(Obj);

So I guess I kind of created a um...embed tag and wmode in one...or sorta. I really don't understand it myself but at least the damn thing works! I can even talk to the flash movie with the flashID name through javascript and send commands to javascript with getURL ("javascript myfunction()") in actionscript. Plus this is all loaded in the head of the document which means just one line of code to load the source and I'm playing with layers with transparent Flash now in both IE and Netscape...YEA!