Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Drop down menu for Flash object

    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.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Here try this
    Code:
    <!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.
    Attached Files Attached Files
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •