...

View Full Version : Drop down menu for Flash object



asx001
02-29-2008, 04:22 AM
I would like to create a drop down menu similar to the one that displays images as in:

http://www.javascriptkit.com/script/cut173.shtml

But rather than for images, I would like it to open and display also flash object on the one webpage from the drop down menu.

Can this be done? and if so anyone give me some hints on how to code it.

I have tried to replace the image name (heart.jpg) with the flash object name (animation.swf) but this did not work.

Thanks in advance.

_Aerospace_Eng_
02-29-2008, 04:49 AM
Here try this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
function showAnimation(what)
{
var flashfile = what.split(',')[0]+'.swf';
var width = what.split(',')[1];
var height = what.split(',')[2];
var so = new SWFObject(flashfile, "mymovie", width, height, "8", "#FFFFFF");
so.addParam('scale','exactfit');
so.write("flashcontent");
}
window.onload = function()
{
showAnimation(document.getElementById('flash').options[document.getElementById('flash').selectedIndex].value);
}
</script>
</head>

<body>
<form action="#" method="post">
<select name="flash" id="flash" size="1" onChange="showAnimation(this.options[this.selectedIndex].value)">
<!--the value of each option contains three items separated by a comma, flash file name (no extension), width, height-->
<option selected value="animation1,100,100" selected="selected">Animation 1</option>
<option selected value="animation2,50,75">Animation 2</option>
<option selected value="animation3,75,100">Animation 3</option>
</select>
</form>
<div id="flashcontent">A flash animation should appear here</div>
</body>
</html>
Attached are the files you need. swfoject.js comes from http://blog.deconcept.com/swfobject/ so if you need to parameters or something read the documentation.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum