Swfobject 2.1 Flex template. HistoryManager and DeepLinking supported as well

[UPDATE] I've updated template to SWFObject 2.1
And there is a bit smarter way to register flexApplication with BrowserHistory:

var flashvars = {
name1: "hello",
name2: "world",
name3: "foobar"
};
var params = {
menu: "false"
};
var attributes = {
id: "${application}",
name: "${application}"
};

swfobject.embedSWF ( "${swf}.swf", "${application}_div", "${width}", "${height}", "${version_major}", "expressInstall.swf", flashvars, params, attributes );
swfobject.addLoadEvent(loadEventHandler);
function loadEventHandler() {
BrowserHistory.flexApplication = swfobject.getObjectById("${application}");
}



I have been using Geoff Stearns' SWFObject for a long time. I think it will be useful to share my index.template.html that tuned for using with SWFObject 2 2.1. I was inspired with Ted Patrick's FXWidget project that uses SWFObject 1.5 for embedding flex content to html page. So now it supports HistoryManager and DeepLinking.
I've made few little changes in history.js to let content embed with SWFObject work with HistoryManager and Deeplinking - I've replaced 'embed' with 'object' at lines 115 and 131 due to the fact that
SWFObject's base markup uses the nested-objects method.

Project Archive [updated - 07-07-2008] ( broken link has been fixed)


Have fun with it!
Cheers!

12 comments:

Ted Patrick said...

Great work!

Oleg Filipchuk said...

thanks Ted.
It would be nice to have in next Flex Builder the possibility to choose what html template you want to use with particular project.

Theo said...

May I plug my BrowserManager-SWFAddress integration kit? It allows you to use SWFAddress instead of Adobe's history code, which gives you Google Analytics-integration more or less for free.

http://developer.iconara.net/objectlib/flex-browsermanager-swfaddress.html

Oleg Filipchuk said...

For sure Theo. I think it's good idea.

Quentin said...

Thanks a million...
it works like a charm

bobby said...

The SWFObject project team has recently also worked on this issue, by updating history.js and FABridge.js in such way that they work with both Flex publishing templates and SWFObject publishing:

http://code.google.com/p/swfobject/wiki/flex

jonbcampos said...

Very nice. I actually have had this same work around running on my site D-Flex.org. Check it out (good developers view source)

David Strickland said...

After days of struggling the FB3 and urlkit and the other derivatives out there. I stumbled on your site and tried the SWFAddress integration kit.

Wow. This is what I was looking for!!!

Within 30 minutes, I had it working. within 1 hour, I had 75% of the deep linking working.

What a lifesaver!

Jan said...

hi Oleg, the link is dead, could you repost please? thx

Oleg Filipchuk said...

Jan, broken link has been fixed. Thanks.

Denis Volokh said...

Hi, I am going to migrate form default template file to template based on SWFObject. I have one question about your index.template.html. I see that you set body style twice, in script block
swfobject.createCSS("body", "margin:0; padding:0; overflow:hidden; height:100%;");
and in style block:
body { margin: 0px; overflow:hidden }

Is it necessary?

Oleg Filipchuk said...

Hi Denis, no that's not necessary to set it twice - it was left as I was testing different style settings.