Click to See Complete Forum and Search --> : dynamic flash object creation -> probs


Marius
07-10-2003, 04:45 AM
Hi,

I'd like to create a javascript that creates and adds an flash object to the site with appropriate size properties.

Everything works so far, but the flash movie isn't presented.

After decompiling the script I found out that from all the outerHTML code ...


"<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#
version=6,0,0,0 height=181 width=250>
<PARAM NAME=\"_cx\" VALUE=\"5080\">
<PARAM NAME=\"_cy\" VALUE=\"5080\">
<PARAM NAME=\"FlashVars\" VALUE=\"5080\">
<PARAM NAME=\"Movie\" VALUE=\"test.swf\">
<PARAM NAME=\"Src\" VALUE=\"test.swf\">
<PARAM NAME=\"WMode\" VALUE=\"Window\">
<PARAM NAME=\"Play\" VALUE=\"-1\">
<PARAM NAME=\"Loop\" VALUE=\"-1\">
<PARAM NAME=\"Quality\" VALUE=\"High\">
<PARAM NAME=\"SAlign\" VALUE=\"\">
<PARAM NAME=\"Menu\" VALUE=\"-1\">
<PARAM NAME=\"Base\" VALUE=\"\">
<PARAM NAME=\"AllowScriptAccess\" VALUE=\"always\">
<PARAM NAME=\"Scale\" VALUE=\"ShowAll\">
<PARAM NAME=\"DeviceFont\" VALUE=\"0\">
<PARAM NAME=\"EmbedMovie\" VALUE=\"-1\">
<PARAM NAME=\"BGColor\" VALUE=\"\">
<PARAM NAME=\"SWRemote\" VALUE=\"\">"


one caracter is disturbing flash. Its this line:
<PARAM NAME=\"Movie\" VALUE=\"test.swf\"> :mad:
the backslash in the file parameter is the problem.

<PARAM NAME=\"Movie\" VALUE="test.swf">
would work.

So i decided to replace all (/") parts with a ('), but all the replace functions didn't work correctly. Mainly because I don't understand the definition of a regular expression. :rolleyes:

The whole code is looking like this:

/* Die Replace Funktionen zum Testen */
function replaceStr(text,expression,value)
{
var exp = new RegExp(expression,'g');
return text.replace(exp,value);
}

function checksize()
{
if (Fensterweite() <= 500) {
var Flashobj = document.createElement("object");
Flashobj.classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
Flashobj.codeBase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0";
Flashobj.height = "181";
Flashobj.width = "250";
Flashobj.Movie = "test.swf";
Flashobj.Quality2 = "High";
Flashobj.EmbedMovie = "True";

/* Funktion um die automatisch Eingefügten '/"' Zeichen zu ersetzen:*/
fehler;
var htmlcode = Flashobj.outerHTML;
// htmlcode.replace(/\/g,"");
htmlcode = replaceStr(htmlcode,"\\","");
//Flashobj.outerHTML = htmlcode;

var Plazierung = document.getElementById("Flashlayer");
Plazierung.appendChild(Flashobj);

//window.history.go(0);
//location.reload();
//fehler;
}
}

Anyone an idea of how to correct this parameter or another way of dynamically inserting an flash objekt in a html page?

Any idea or help is appreaciated :)

Greetz
Marius

P.s. Sorry for my bad english and any mistake is just for your pleasure. ;)

Lotus
07-10-2003, 04:50 AM
Well, first of all it seems as if though you have forgotten to add </object> in the very end of the code that displays the actual object.

And all those functions in the end of your post... you have to put them inside <script></script> tags!

Marius
07-10-2003, 05:45 AM
The script is in <script> </script> tags, ant not inbetween the <object> tag because it shoult generate this tag an insert it.

So it creats the object as an DOM model and adds all those parameters. The result is the outerHTML code so it doesn't need an existing <object> tag in the html code.

All that prevents the flash from beeing shown is the "\" in the movie parameter, because it seems like the flash player doesn't accept \" as an internal " in this parameter an thus doesn't find the file.

So how can i delete those backslashes or how can i work arround this issue? quite a little bit complex though :)

Greetz
Marius