function getFlashMovieObje" name="description" /> function getFlashMovieObje" />

using javascript function call to play multiple swf files


I'm using the following code to trigger the playing of a swf file when an image is clicked. It works great, but I want to have multiple swf files that are each triggered by diffent images.

<script language="JavaScript"> function getFlashMovieObject(movieName) { if (window.document[movieName]) { return window.document[movieName]; } if (navigator.appName.indexOf("Microsoft Internet")==-1) { if (document.embeds && document.embeds[movieName]) return document.embeds[movieName]; } else // if (navigator.appName.indexOf("Microsoft Internet")!=-1) { return document.getElementById(movieName); } } function PlayFlashMovie() { var flashMovie=getFlashMovieObject("Flash1"); flashMovie1.Play(); } </script>

then the movie is triggered:

<div class="buttonimage1" style="background-color: #FFFFFF;"> <img src="icon1-small.png" alt="icon 1" onmousedown="PlayFlashMovie();" >

I want to add this so that (for example) clicking buttonimage2 would trigger "movie 2" and buttonimage3 would trigger "movie 3" etc...

<div class="buttonimage2" style="background-color: #FFFFFF;"> <img src="icon2-small.png" alt="icon 1" onmousedown="PlayFlashMovie();" >

<div class="buttonimage3" style="background-color: #FFFFFF;"> <img src="icon3-small.png" alt="icon 1" onmousedown="PlayFlashMovie();" > </div>

How can I set the getFlashMovieOject function for multiple movie names? I've tried a couple of things but seem to be missing something and I'm pretty new to js. A little help would be greatly appreciated. Thanks


You could have the PlayFlashMovie function take an argument:

function PlayFlashMovie(name) { var flashMovie=getFlashMovieObject(name); flashMovie.Play(); }

And then pass it like so:

<img src="icon1-small.png" alt="icon 1" onmousedown="PlayFlashMovie('Flash1');" > <img src="icon2-small.png" alt="icon 2" onmousedown="PlayFlashMovie('Flash2');" >



  • flashMovie.Play is not a function
  • PHP/MySql Multiple Dropdowns dont want option values visible in page source
  • php printf adds number to output
  • why does sort with uniq not work together
  • Display custom checkout field value in Woocommerce admin order edit pages
  • SurfaceView or GLSurfaceview?
  • Best way with relation tables
  • Microdata and multiple opening in a day
  • Can I access the active version on SAP Cloud Platform of HTML5 apps through a api?
  • How to access a value using a space-separated key?
  • AngularJS: accessing scope variables in $routeProvider
  • Create a demo of my static program analyzer as a web application? [without sending .jar files to cli
  • Google Chrome does not open application on Deep Link on Android
  • Get table row based on radio button using prototype/Javascript
  • load an ad (div) just once on first load
  • Translating route segments with ZF's gettext adapter
  • TextView shadow not showing up in preview - although working on real device
  • Phoenix on Heroku: error R10
  • How to check if a RxJS Observable contains a string in Angular2?
  • How to navigate between different html pages in Windows 8 Metro application using javascript?
  • Is it really posible to close a PhoneGap App?
  • Select multiple items in JTextPane
  • How do I customize header and footer in jqgrid?
  • Textbox validation in jquery
  • use a single handler for multiple inputs onChange events
  • Undefined navigator.push React-native 0.43.4
  • Chart.js Multiple dataset
  • How do I get HTML corresponding to current DOM tree?
  • JQuery Internet Explorer and ajaxstop
  • JSON response opens as a file, but I can't access it with JavaScript
  • Change an a tag attribute in JavaScript based on screen width
  • AngularJs get employee from factory
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Is there any way to bind data to data.frame by some index?
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • How to push additional view controllers onto NavigationController but keep the TabBar?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?