0

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.

2 Answers 2

3

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
    );
};
Sign up to request clarification or add additional context in comments.

Comments

0

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");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.