SWFAddress 2.1 & SWFObject 2 Work Together.
I spent a good hour yesterday trying to get SWFAddress 2.1 and SWFObject 2 to work together. First off, they do work together. Second, there's nothing to it. Then why did it take me an hour? Because I'm a dummy and I had the order in which each JavaScript set was called. In hindsight, this is common sense, but the golden ticket here is calling SWFAddress javascript BEFORE declaring the SWFObject. This more applies to people using the dynamic way of embedding the SWFObject. ie:
<head>
<title>SWFObject v2.0 - step 3</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript" src="js/swfaddress.js"></script>
<script type="text/javascript">
swfobject.embedSWF('website.swf', 'website', '100%', '100%', '9.0.45',
'swfobject/expressinstall.swf', {}, {bgcolor: '#CCCCCC', menu: 'false'}, {id: 'website'});
</script>
</head>
Silly right? I saw a couple of posts out there of people having a hard time getting this going. Once I flipped the JS declaration, it worked. And I felt kinda dumb. But hey ... That's life.
BTW: both SWFAddress and SWFObject 2 are pretty amazing and should be worked into your site/app flow if they aren't already.
May 21st, 2008 - 01:19
Ogh…


You were lucky anyway: You spent only good hour. I spent all day, I even have translated all swfaddress.js code into human friendly, debugged that for several hours. I couldnt even think about your discovery
Now I want to shoot myself
Anyway thanks…
May 21st, 2008 - 12:16
hahah .. no doubt.
I think we’ve all been there before. Possibly weekly even.
May 25th, 2008 - 21:41
Thanks for posting this — you just saved me loads of time.
May 27th, 2008 - 12:48
We’re doing the swfObject2/swfAddress2 thing here too, and we went one further and used swfMacMouseWheel2 too! too.
July 11th, 2008 - 08:47
Thanks!!!
It also seems that you have to add this “{id: ‘website’}” attribute to your javascript.
Otherwise the swfaddress won’t work correct, the event dispatched when going back in your browserhistory doesn’t get received in flash…
I don’t understand why though… :/
August 28th, 2008 - 03:06
Thanks! I spent one and a half day trying solve this! Now it works!
September 1st, 2008 - 12:22
THANK YOU! I, too, spent more than an hour on this. Didn’t realize until just a few minutes ago that the difference between ALL of the examples I saw and downloaded online and my files was that I was using SWFObject 2. After that realization, it only took a few minutes for me to google your post, and come up with the solution!
September 2nd, 2008 - 02:23
Hi all, just a few clarifications:
The swfaddress.js needs to be included after swfobject.js and before the embed declaration because it adds a hook that automates the invocation of SWFAddress.addId(flashObjId). If you need to include the files differently this SWFAddress method can be called manually and everything will function normally.
The id attribute is also very important because the script somehow needs to find the Flash object and notify it about address changes. With SWFObject 1.5 this parameter was mandatory but it can be easily skipped with the new API.
September 16th, 2008 - 19:39
Still Doesn’t work for me… And I’ve spent days on this now!
September 18th, 2008 - 13:22
Are you getting any errors or is it just flat out not working?
October 28th, 2008 - 21:50
Dang, the lack of id was what got me. Only lost a couple of hours thanks to you. Much appreciated.
November 23rd, 2008 - 04:42
I will name my first son after you… little Nobien
January 27th, 2009 - 03:34
Doh – wish I found this post earlier.
Nice one – thanks!
March 3rd, 2009 - 13:54
Cheers for the tip. Slightly off topic though, wondering if you’ve come across this before. I’m using the two together but I can’t get swfaddress to work. When I click a navigation button the url in the browser window doesn’t change. I’ve put traces everywhere and as far as I can see all the right listeners and handlers are being called. Traces are outputting the URL, everything seems fine but the URL bar just doesn’t change. Any ideas?
Cheers.
KJ
March 10th, 2009 - 14:48
Wooah ! Thanks dude !
March 23rd, 2009 - 00:57
Wow, you definitely saved me a ton of time. Thank you for posting!
April 8th, 2009 - 14:36
KJ,
Had the same problem. Added allowScriptAccess:’always’ to the embed params and it worked!
April 22nd, 2009 - 17:37
Hey all,
I’ve got SWFAddress (almost) working. The URL changes, but I can’t get the back/forward buttons to change the SWF:
http://www.boston.com/lifestyle/green/gallery/0422_earthslider/
* SWFAddress is called before SWFObject
* SWFObject gives it an id name
* My SWFAddressEvent.CHANGE is firing when someone switches to a new photo using the Flash controls, but still not with the back/foward buttons
…. are there any other secrets? Doctypes? What am I missing?
Thanks!
- Jared
April 23rd, 2009 - 09:00
Hi Jared,
There are no secrets (as far as I know). Looking at the source for the boston.com gallery, you may want to try to flip the order in which you’re calling SWFObject and SWFAddress. Place the SWFAddress after the SWFObject JavaScript declaration.
ie:
– call to swfObject JS –
– call to swfAddress JS –
–swfObject SWF embed info –
Hopefully that will help.
April 23rd, 2009 - 10:41
Hey Marc,
Looks like I found the problem — Adobe! Turns out the ActiveContent script some how conflicts with SWFAddress and SWFObject to cause the failure of the back/forward buttons. How exactly? You got me
December 15th, 2009 - 19:20
D’oh! Unbelievable that I missed such a thing
Thank you very much for posting this!
December 16th, 2009 - 23:20
just spent an hour myself going though this, probably would have spent another few if I didn’t stumble upon this post! Thanks!
May 24th, 2010 - 06:59
Another half day down the drain here.
the shitty thing is that when you include the js’s in the wrong order, some methods do work, like SWFAddress.getBaseURL and SWFAddress.setTitle.
SWFAddress.getValue however returns nothing.
December 16th, 2010 - 08:45
Thanks for pointing this out. Wasted half a day here as well, but this post saved me from wasting many more hours