Reputation: 5800
IS there a clean and concise way to put multiple swfobjects into one page in HTMl, bearing in mind they will all need different flashvars?
Below is just one:
<script type="text/javascript">
var flashvars = {};
var params = {};
var attributes = {};
swfobject.embedSWF("/swf/AllBookings.swf", "no-flash", "620", "365", "9.0.0", false, flashvars, params, "all_bookings");
</script>
I could copy and paste this a few times and change the names, but there must be a nice way.
Upvotes: 0
Views: 3075
Reputation: 5858
Put all relevant parameters into an array and iterate over it:
var swfs = [
{
url: '/swf/AllBookings.swf',
id: 'no-flash',
width: 620,
height: 365,
flashvars: {},
params: {},
attributes: {}
},
{
url: '/foo.swf',
id: 'bar',
width: 620,
height: 365,
flashvars: {},
params: {},
attributes: {}
}
];
for (var i = 0; i < swfs.length; i++) {
var swf = swfs[i];
swfobject.embedSWF(
swf.url, swf.id, swf.width, swf.height, "9.0.0", false,
swf.flashvars, swf.params, swf.attributes
);
};
Upvotes: 3
Reputation: 23311
You only need to copy and paste this part:
swfobject.embedSWF("/swf/AllBookings.swf", "no-flash", "620", "365", "9.0.0", false, flashvars, params, "all_bookings");
Upvotes: 0