There are newer methods, but this one is tried and proven for a basic start. It's the 2006 Adobe version with some revision and adaptation thrown in:
- Create a file called AC_RunActiveContent.js and paste this in, then upload to your scripts folder:
Code:
//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
if (src.indexOf('?') != -1)
return src.replace(/\?/, ext+'?');
else
return src + ext;
}
function AC_Generateobj(objAttrs, params, embedAttrs)
{
var str = '<object ';
for (var i in objAttrs) {
str += i + '="' + objAttrs[i] + '" ';
};
str += '>';
for (var i in params) {
str += '<param name="' + i + '" value="' + params[i] + '" /> ';
};
str += '<embed ';
for (var i in embedAttrs){
str += i + '="' + embedAttrs[i] + '" ';
};
str += '>';
document.write(str);
// document.write('</embed>');
// document.write('</object>');
}
function AC_FL_RunContent(){
var ret =
AC_GetArgs
( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
, "application/x-shockwave-flash"
);
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_SW_RunContent(){
var ret =
AC_GetArgs
( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
, null
);
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
var ret = new Object();
ret.embedAttrs = new Object();
ret.params = new Object();
ret.objAttrs = new Object();
for (var i=0; i < args.length; i=i+2){
var currArg = args[i].toLowerCase();
switch (currArg){
case "classid":
break;
case "pluginspage":
ret.embedAttrs[args[i]] = args[i+1];
break;
case "src":
case "movie":
args[i+1] = AC_AddExtension(args[i+1], ext);
ret.embedAttrs["src"] = args[i+1];
ret.params[srcParamName] = args[i+1];
break;
case "onafterupdate":
case "onbeforeupdate":
case "onblur":
case "oncellchange":
case "onclick":
case "ondblClick":
case "ondrag":
case "ondragend":
case "ondragenter":
case "ondragleave":
case "ondragover":
case "ondrop":
case "onfinish":
case "onfocus":
case "onhelp":
case "onmousedown":
case "onmouseup":
case "onmouseover":
case "onmousemove":
case "onmouseout":
case "onkeypress":
case "onkeydown":
case "onkeyup":
case "onload":
case "onlosecapture":
case "onpropertychange":
case "onreadystatechange":
case "onrowsdelete":
case "onrowenter":
case "onrowexit":
case "onrowsinserted":
case "onstart":
case "onscroll":
case "onbeforeeditfocus":
case "onactivate":
case "onbeforedeactivate":
case "ondeactivate":
case "type":
case "codebase":
ret.objAttrs[args[i]] = args[i+1];
break;
case "width":
case "height":
case "align":
case "vspace":
case "hspace":
case "class":
case "title":
case "accesskey":
case "name":
case "id":
case "tabindex":
ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
break;
default:
ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
}
}
ret.objAttrs["classid"] = classid;
if (mimeType) ret.embedAttrs["type"] = mimeType;
return ret;
}
- Paste this into the HEAD of your HTML document:
HTML Code:
<script src="PATH-TO-SCRIPT-DIRECTORY/AC_RunActiveContent.js" type="text/javascript"></script>
<!--[if IE]>
<script type="text/vbscript">
Function VBGetSwfVer(i)
on error resume next
Dim swControl, swVersion
swVersion = 0
set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))
if (IsObject(swControl)) then
swVersion = swControl.GetVariable("$version")
end if
VBGetSwfVer = swVersion
End Function
</script>
<![endif]-->
- Add this in the body, making necessary changes as apply:
HTML Code:
<div id="content">
<h1>YouTube Video of the Week</h1>
<noscript><div><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="425" height="344" id="youtubevideo">
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="true" />
<param name="movie" value="http://www.youtube.com/v/e-yldqNkGfo" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
</object>
</div>
<div class="alternate_content">
<p class="message"><a title="Return to Home page" href="/"><span>Scripting required to display this media.</span></a></p>
<p class="home"><a href="/"><span> Home </span></a></p>
</div></noscript>
<script type="text/javascript"><!--
// Adobe script, adapted.
// http://www.youtube.com/watch?v=e-yldqNkGfo
// becomes this
// http://www.youtube.com/v/e-yldqNkGfo
AC_FL_RunContent(
'codebase','https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
'width','425',
'height','344',
'id','youtubevideo',
'align','middle',
'src','youtubevideo',
'quality','high',
'wmode','transparent',
'name','youtubevideo',
'allowscriptaccess','always',
'allowFullScreen','true',
'pluginspage','https://www.macromedia.com/go/getflashplayer',
'movie','http://www.youtube.com/v/e-yldqNkGfo
); //end AC code
document.write('<\/embed><\/object>');
//--></script>
<h2>• Food Fight •</h2>
</div>
- Position and style container as required.
A large part of the process is determining which Flash version the user has installed, as well as which browser (to a degree, this is an older method). A number of sites weighed in on this method back in the day. I can't even remember all the considerations and workarounds that have been incorporated since then. The core is still relatively untouched, and bears the original name, should you wish to Google it, or look for a newer version.
Note the conditional comment. This version requires the ActiveX object to fire in IE. The script is VB, and needs to be embedded, not placed in the external file. Order of execution of scripts is important, too, so be sure to load the AC javascript code first.
More than this I cannot say, just now, but I'll bet you will find lots on the subject with a little looking. Ciao!