PDA

View Full Version : random flash movie



grimnir
10-06-2006, 03:17 PM
Hi!
I am trying to find some javascript or other type of script that lets me load random flash movies into a web page. The ones I have found so far work ok, but trigger the activeX security feature, so I need an updated version.

Has anyone seen this or have the skills to adjust the javascript I am using?
Thanks,
Roger

benslayton
10-06-2006, 03:44 PM
Can you post the javascript here?:)

grimnir
10-06-2006, 04:00 PM
Of course! :)

The random script goes like this:
________________________________________________________

<script language="JavaScript">

// Generate a Random Number
var randomnumber = Math.round(Math.random()*3);

// Select a movie and execute the corresponding function
if (randomnumber == 1)

{movie1();}

else if (randomnumber == 2)

{movie2();}

else {movie3();}

//Functions to write out the correct flash movie resource.

function movie1(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"180\" height=\"180\"><param name=movie value=\"http://www.mticoaching.se/swf/samplecd/cdbanner_idealvikt.swf\"><param name=quality value=high><embed src=\"http://www.mticoaching.se/swf/samplecd/cdbanner_idealvikt.swf\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"180\" height=\"180\"></embed></object>")
}

function movie2(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"180\" height=\"180\"><param name=movie value=\"http://www.mticoaching.se/swf/samplecd/cdbanner_oro1.swf\"><param name=quality value=high><embed src=\"http://www.mticoaching.se/swf/samplecd/cdbanner_oro1.swf\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"180\" height=\"180\"></embed></object>")
}

function movie3(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"180\" height=\"180\"><param name=movie value=\"http://www.mticoaching.se/swf/samplecd/cdbanner_oro1.swf\"><param name=quality value=high><embed src=\"http://www.mticoaching.se/swf/samplecd/cdbanner_oro1.swf\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"180\" height=\"180\"></embed></object>")
}

</script>

________________________________________________________

And the standard Flash script goes like this:

<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js. In Flash, run \"Apply Active Content Update\" in the Commands menu to copy AC_RunActiveContent.js to the HTML output folder.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
'width', '180',
'height', '180',
'src', 'swf/samplecd/idealvikt',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'top',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'transparent',
'devicefont', 'false',
'id', 'cdbanner_idealvikt',
'bgcolor', '#ffffff',
'name', 'cdbanner_idealvikt',
'menu', 'true',
'allowScriptAccess','sameDomain',
'movie', 'swf/samplecd/cdbanner_idealvikt',
'salign', 'lt'
); //end AC code
}
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="180" height="180" id="cdbanner_idealvikt" align="top">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="swf/samplecd/cdbanner_idealvikt.swf" /><param name="quality" value="high" /><param name="salign" value="lt" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /> <embed src="swf/samplecd/cdbanner_idealvikt.swf" quality="high" salign="lt" wmode="transparent" bgcolor="#ffffff" width="180" height="180" name="cdbanner_idealvikt" align="top" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</noscript>

________________________________________________________

These to need to be combined somehow, or perhaps improved as well, so that I can have random movies and still avoid the security bar popping up.

Thanks!
Roger

jetho
09-26-2007, 10:34 AM
You've probably figured it out by now, but I just spent an hour on the same problem and here is my solution (which will also allow floating menu bars on top and checks for correct flash version):


<!-- FLASH OBJECT -->
<script language="JavaScript" type="text/javascript">
<!--
// Version check based upon the values entered above in "Globals"
var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

// Check to see if the version meets the requirements for playback
if (hasReqestedVersion) {
// if we've detected an acceptable version
// embed the Flash Content SWF when all tests are passed
// Generate a Random Number
var randomnumber = Math.round(Math.random()*2);

// Select a movie and execute the corresponding function
if (randomnumber == 1)

{movie1();}

else {movie2();}

//Functions to write out the correct flash movie resource.

function movie1(){
AC_FL_RunContent(
"src", "/images/firewire",
"play", "true",
"width", "700",
"height", "276",
"align", "middle",
"wmode", "opaque",
"id", "/images/firewire",
"quality", "high",
"bgcolor", "#FFFFFF",
"name", "/images/firewire",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
'codebase', 'http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
"pluginspage", "http://www.macromedia.com/go/getflashplayer"
)
}

function movie2(){
AC_FL_RunContent(
"src", "/images/assr2",
"play", "true",
"width", "700",
"height", "276",
"align", "middle",
"wmode", "opaque",
"id", "/images/assr",
"quality", "high",
"bgcolor", "#FFFFFF",
"name", "/images/assr2",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
'codebase', 'http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
"pluginspage", "http://www.macromedia.com/go/getflashplayer"
)
}
} else { // flash is too old or we can't detect the plugin
var alternateContent = '<a href="http://www.interacoustics-us.com/Products/ABR_EvokedPotentials/InteracousticsASSR.asp"><img src="/images/ASSR2.gif" width="700" height="276" border="0"></a>';
document.write(alternateContent); // insert non-flash content
}
// -->
</script>


Don't forget to place this script inside the <head> tag and adjust the player version:

<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 6;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// -----------------------------------------------------------------------------
// -->
</script>

allanmcnabb
03-07-2009, 05:41 PM
Hi,

Thanks! This was perfect!

Allan

digitalguru
03-22-2009, 04:31 PM
Hi,

Thanks! This was perfect!

Allan

Allan,

I'm trying to do the same thing but i don't know where to place that code in my webpage. I'm trying to get it into a table.

Thanks,

Phillip Howe