Multiple swfobjects on one page (using Dynamic method)

947 views
Skip to first unread message

astembridge

unread,
May 2, 2008, 12:11:47 PM5/2/08
to SWFObject
I’m attempting to migrate from 1.5 to 2.0 – I understand there are
numorous differences. I will continue using the dynamic method, like
with 1.5

According to 2.0 documentation, creating multiple swfobjects one one
page is as easy as:

“Just repeat steps 1 and 3 to embed multiple SWF files into one HTML
page”

Is there an explicit example of this somewhere? I tried the following
and no javascript errors were reported, but the swf’s didn’t appear:

- - -
<head>
<SCRIPT language='JavaScript' src='includes/swfobject_2_0.js'></
SCRIPT>
<script type='text/javascript'>
swfobject.embedSWF('swf/fade_welcome.swf', 'flashcontent_welcome',
100, 29, '7.0.0');
swfobject.embedSWF('swf/fade_news.swf', 'flashcontent_news', 70, 29,
'7.0.0');
swfobject.embedSWF('swf/fade_services.swf', 'flashcontent_services',
100, 29, '7.0.0');
</script>
</head>

<table cellpadding=1 cellspacing=0 border=0 align=center>
<tr>
<td valign=top title='Welcome'><div id='flashcontent_welcome'><a
style='border-bottom:none;' href=index.php title='Welcome'>Welcome</
div></td>
<td valign=top title='News and Information'><div
id='flashcontent_news'><a style='border-bottom:none;' href=news.php
title='News and Information'>News</a></div></td>
<td valign=top title='Client Services'><div
id='flashcontent_services'><a style='border-bottom:none;'
href=services.php title='Client Services'>Services</a></div></td>
</tr>
</table>

For comparison with 1.5 (again, 2.0 is vastly different) I created
each button like this:

so_welcome = new SWFObject('swf/fade_welcome.swf', 'welcome', 100, 29,
7, '#336699');
so_welcome.write('flashcontent_welcome');

<div id='flashcontent_welcome'><a style='border-bottom:none;'
href=index.php title='Welcome'>Welcome</div>


Am I leaving out any steps in setting up 2.0?

astembridge

unread,
May 2, 2008, 3:42:21 PM5/2/08
to SWFObject
I noticed that when I view the page on my server, the movies are
displaying properly in IE 7, but not Firefox. If I view the same
page locally (through my filesystem), Firefox displays the movies
correctly. I've checked and triple checked that the swf files are
referenced properly (by entering the same address in windows explorer,
and the flash file opens in Adobe Flash).

Any assistance will be greatly appreciated.

Thank you.

astembridge

unread,
May 2, 2008, 3:46:52 PM5/2/08
to SWFObject
Just a quick follow-up to my last email.. I placed my swf files in the
same directory as the script itself and still, Firefox does not show
the movies.

ryan-g2

unread,
May 3, 2008, 7:50:26 AM5/3/08
to SWFObject
Not sure, but try removing the flash divs from the table. DOM
scripting is sometimes difficult inside tables.

Probably better to use CSS only on your page, anyway.

extfsh

unread,
May 13, 2008, 3:06:37 PM5/13/08
to SWFObject
heya i was wondering if you'd found a solution to this? i've been
trying to make sense of the exact same thing.

Bobby

unread,
May 13, 2008, 3:59:26 PM5/13/08
to SWFObject
Multiple SWFs, it's really easy :-) Please check out the sample pages
from the wiki, e.g.:
http://www.swffix.org/swfobject/testsuite/test_dynamic_multiple.html

@astembridge: i also think that your issue is caused by your table
layout. SWFObject 2 replaces your divs, like <div
id='flashcontent_welcome'>... with <object
id="flashcontent_welcome" ...>, while SWFObject 1.5 only replaces the
div's contents. So make sure that your layout still holds up, e.g. you
could add the following style rules:
object { display:block; }
#flashcontent_welcome { width:100px; height:29px; }
etc.

extfsh

unread,
May 13, 2008, 4:15:57 PM5/13/08
to SWFObject
thanks for the reply, but this is what i'd been doing and it still
isn't working. i basically have a site where the <head> is an includes
shared by all pages, and the flash files i need to add are located on
two separate pages. if i set up my swfobject like shown, only the
first swf will display.

extfsh

unread,
May 13, 2008, 5:29:12 PM5/13/08
to SWFObject
turns out all i needed to do was call the js for each instance.
doesn't make sense to me, but it works...

<script type="text/javascript" src="js/swfobject.js"></
script>
<script type="text/javascript">
swfobject.embedSWF("swfs/checkbox_63x64.swf", "flash-
container-1", "63", "64", "9.0.0", "expressInstall.swf", "false",
{wmode:"transparent"});
</script>

<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("swfs/hp_movie0506.swf", "flash-
container-2", "693", "186", "9.0.0", "expressInstall.swf", "false",
{wmode:"transparent"});
</script>

Aran Rhee

unread,
May 13, 2008, 9:18:25 PM5/13/08
to swfo...@googlegroups.com
You don't need to include the swfobject.js file multiple times, but of
course you have to call embedSWF for each file you want displayed on the
screen...

It should look like:

<script type="text/javascript" src="js/swfobject.js"></script>

<script type="text/javascript">
swfobject.embedSWF("swfs/checkbox_63x64.swf", "flash-container-1",


"63", "64", "9.0.0", "expressInstall.swf", "false", {wmode:"transparent"});

swfobject.embedSWF("swfs/hp_movie0506.swf", "flash-container-2",


"693", "186", "9.0.0", "expressInstall.swf", "false",
{wmode:"transparent"});
</script>

Aran

wookee

unread,
Jun 13, 2008, 6:49:23 AM6/13/08
to SWFObject
Hello everyone....humbly on my knees in appreciation of anyone who can
help me with my multiple SWF problem.

I have tried static and dynamic implementations,
I have tried with or without using swfobject,
I have tried the old swfobject and followed instructions exactly as
written
I have been reading and trying suggestions from forums for over 48
hours straight,
I have tried every variable you can throw at me

....and I can NOT get multiple SWFs to display on the page.

If I try opening the page on my local machine it works. When I upload
the page and try it.....no good.

I can view SWF on other web pages....I have the latest version of
flashplayer installed.

On my page, only the first SWF appears....there is white space where
the other 2 are supposed to be.

Here is the page I'm using as a test to get it to work:
http://www.worldmassage.com/vegan/test2.htm

Oh....and which swfobject.js file am I supposed to upload to my site??
When you download swfobject2.0 it has 2 different js files included,
one is 21KB (in the SRC folder) the other is 9KB (in the root
directory). Incidentally, I've tried both files....no difference.

Here's what I've got in my <head> tag:

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
var params = {};
params.play = "false";
params.loop = "false";
var attributes = {};
swfobject.embedSWF("video/meatrix.swf", "one", "480", "310", "6",
false, flashvars, params, attributes);
swfobject.embedSWF("video/m2.swf", "two", "480", "310", "6",
false, flashvars, params, attributes);
swfobject.embedSWF("video/meatrix_2_5.swf", "three", "480", "310",
"6", false, flashvars, params, attributes);
</script>
</head>


Then in the <body> I've got
<div id="one">
<div id="two">
<div id="three">
with the other code generated by the swfobject online generator and
each div is separated by a <br>

That's it....I've just left the page blank for now to get this much
working.

Thank you
Thank you
Thank you if you can help me with this.

Wook.

On May 14, 10:18 am, "Aran Rhee" <aran.r...@gmail.com> wrote:
> You don't need to include the swfobject.js filemultipletimes, but of
> course you have to call embedSWF for each file you want displayed on the
> screen...
>
> It should look like:
>
> <script type="text/javascript" src="js/swfobject.js"></script>
>
> <script type="text/javascript">
> swfobject.embedSWF("swfs/checkbox_63x64.swf", "flash-container-1",
> "63", "64", "9.0.0", "expressInstall.swf", "false", {wmode:"transparent"});
> swfobject.embedSWF("swfs/hp_movie0506.swf", "flash-container-2",
> "693", "186", "9.0.0", "expressInstall.swf", "false",
> {wmode:"transparent"});
> </script>
>
> Aran
>
> -----Original Message-----
> From: swfo...@googlegroups.com [mailto:swfo...@googlegroups.com] On
>
> Behalf Of extfsh
> Sent: Wednesday, 14 May 2008 7:29 AM
> To: SWFObject
> Subject: Re:Multipleswfobjects on one page (using Dynamic method)
>
> turns out all i needed to do was call the js for each instance.
> doesn't make sense to me, but it works...
>
> <script type="text/javascript" src="js/swfobject.js"></
> script>
> <script type="text/javascript">
> swfobject.embedSWF("swfs/checkbox_63x64.swf", "flash-
> container-1", "63", "64", "9.0.0", "expressInstall.swf", "false",
> {wmode:"transparent"});
> </script>
>
> <script type="text/javascript"
> src="js/swfobject.js"></script>
> <script type="text/javascript">
> swfobject.embedSWF("swfs/hp_movie0506.swf", "flash-
> container-2", "693", "186", "9.0.0", "expressInstall.swf", "false",
> {wmode:"transparent"});
> </script>
>
> On May 13, 4:15 pm, extfsh <exitf...@gmail.com> wrote:
> > thanks for the reply, but this is what i'd been doing and it still
> > isn't working. i basically have a site where the <head> is an includes
> > shared by all pages, and the flash files i need to add are located on
> > two separate pages. if i set up my swfobject like shown, only the
> > firstswfwill display.
>
> > On May 13, 3:59 pm, Bobby <bobbyvandersl...@gmail.com> wrote:
>
> > >MultipleSWFs, it's really easy :-) Please check out the sample pages

Bobby

unread,
Jun 13, 2008, 7:44:54 AM6/13/08
to SWFObject
In SWFObject 2.0 you cannot share flashvars, params and attributes
JavaScript objects for multiple SWFs (you need to define separate
objects for each SWF).

When you use SWFObject 2.1 beta7, this issue has been fixed. Please
note that this beta is close to its release.

wookee

unread,
Jun 13, 2008, 7:55:06 AM6/13/08
to SWFObject
Thanks for your quick reply Bobby.

I didn't know I was sharing flashvars (I'm a bit new to SWFObject).

I don't want any optional flashvars defined so I just defined
flashvars as "false" in the script that goes in the <head> tag.

What should I do to rectify the problem?

Thanks
Dan

Aran Rhee

unread,
Jun 13, 2008, 7:58:39 AM6/13/08
to swfo...@googlegroups.com
Dan.

One thing I noticed when looking at the server traffic on your test page (
http://www.worldmassage.com/vegan/test2.htm ):

http://www.worldmassage.com/vegan/video/m2.swf does not exist in this
location. Is it actually on the server?

If I modify your code slightly (absolute paths to your sever + change to
meatix.swf which actually exists), then all works:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript"
src="http://www.worldmassage.com/vegan/swfobject.js"></script>
<script type="text/javascript">

swfobject.embedSWF("http://www.worldmassage.com/vegan/video/meatrix.swf",
"one", "480", "310", "9.0.0", false, false, {play:"false",loop:"false"},
false);
</script>
<script type="text/javascript">

swfobject.embedSWF("http://www.worldmassage.com/vegan/video/meatrix.swf",
"two", "480", "310", "9.0.0", false, false, {play:"false",loop:"false"},
false);
</script>
</head>
<body>
<div id="one">
<a href="http://www.adobe.com/go/getflashplayer">
<img
src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gi
f" alt="Get Adobe Flash player">
</a>
</div>
<br>
<div id="two">
<a href="http://www.adobe.com/go/getflashplayer">
<img
src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gi
f" alt="Get Adobe Flash player">
</a>
</div>
</body>
</html>


Please also not Bobby's answer on sharing flashvars etc. ON your test page,
you are fine in that you are defining vars directly in the embedSWF() calls.
In your code below you EITHER need to:

a) grab 2.1 beta 7 of swfobject.js - bug is fixed
b) define separate flashvar, attributes, andparam vars for each embedSWF()
call

Cheers,
Aran

-----Original Message-----
From: swfo...@googlegroups.com [mailto:swfo...@googlegroups.com] On

Behalf Of wookee
Sent: Friday, 13 June 2008 8:49 PM
To: SWFObject

wookee

unread,
Jun 13, 2008, 8:18:34 AM6/13/08
to SWFObject
Hey Aran, you know what I think it is.....swfObject is "case
sensitive" regarding the code in the <head> tag.

I DO have that file m2.swf on my server in the relevant
folder....however the actual name of the file on the server has an
uppercase "M" so, I changed the code to include an uppercase "M" in
the part where you put the file name and now it works.

It doesn't seem to matter whether you use relative or absolute
paths....just the case-sensitivity.

Thanks for helping with that!!

Regards,
Dan.

On Jun 13, 8:58 pm, "Aran Rhee" <aran.r...@gmail.com> wrote:
> Dan.
>
> One thing I noticed when looking at the server traffic on your test page (http://www.worldmassage.com/vegan/test2.htm):
>
> http://www.worldmassage.com/vegan/video/m2.swfdoes not exist in this

Aran Rhee

unread,
Jun 13, 2008, 8:21:59 AM6/13/08
to swfo...@googlegroups.com
It's your web server, not swfobject :)

UNIX servers are generally case sensitive, where as I'm guessing your dev
machine is Windows...

wookee

unread,
Jun 13, 2008, 8:29:09 AM6/13/08
to SWFObject
Correct....you out-nerded me on that one :)

It was driving me nuts...I really appreciate your help.

Dan
> >http://www.worldmassage.com/vegan/video/m2.swfdoesnot exist in this

VUELA

unread,
Jul 1, 2008, 2:03:22 AM7/1/08
to SWFObject
for some strange reason this worked for me too! one header used for
all pages, swfs on different pages, fixed when i repeatedly call the
js for each instance just like you said. weird.




On May 13, 2:29 pm, extfsh <exitf...@gmail.com> wrote:
> turns out all i needed to do was call the js for each instance.
> doesn't make sense to me, but it works...
>
> <script type="text/javascript" src="js/swfobject.js"></
> script>
> <script type="text/javascript">
> swfobject.embedSWF("swfs/checkbox_63x64.swf", "flash-
> container-1", "63", "64", "9.0.0", "expressInstall.swf", "false",
> {wmode:"transparent"});
> </script>
>
> <script type="text/javascript" src="js/swfobject.js"></script>
> <script type="text/javascript">
> swfobject.embedSWF("swfs/hp_movie0506.swf", "flash-
> container-2", "693", "186", "9.0.0", "expressInstall.swf", "false",
> {wmode:"transparent"});
> </script>
>
> On May 13, 4:15 pm, extfsh <exitf...@gmail.com> wrote:
>
> > thanks for the reply, but this is what i'd been doing and it still
> > isn't working. i basically have a site where the <head> is an includes
> > shared by all pages, and the flash files i need to add are located on
> > two separate pages. if i set up my swfobject like shown, only the
> > firstswfwill display.
>
> > On May 13, 3:59 pm, Bobby <bobbyvandersl...@gmail.com> wrote:
>
> > >MultipleSWFs, it's really easy :-) Please check out the sample pages
Reply all
Reply to author
Forward
0 new messages