Monday,
23 Oct 2006
SWFAddress - Deep linking for Flash®
I'm glad to introduce you to our new project that aims to improve the way people use Flash websites and applications. It's been a long time since Kevin Lynch outlined the problem and provided some proof of concept code, but two years later there's still no a solid standard solution.
A few weeks ago we started working on a typical Flash website for a fellow photographer and I thought that it will be great if it supported deep linking. I had some JavaScript code that enables such behaviour for Ajax calls and it was fairly easy to connect it to the Flash movie using ExternalInterface. I also extended the SWFObject initialization in order to simplify the usage of the script as much as possible. This is how SWFAddress was born. As of yesterday it's available under the MIT license.
I'll be happy to hear your comments, suggestions and bug reports. My list for the final release include detection of unsupported browsers, improved Safari support and probably a sample that works with the default Flex 2 templates.
Future improvements may include support for query parameters and custom events for specific URLs.
Learn more and download at the SWFAddress homepage.
Comments:
Would be cool with flashplayer 7 support though.
Still seems like alot of people still are using that...
Thanks for the report. Actually I have never considered the usage of SWFAddress from HTML, but it will nice. I've changed parts of the internal implementation and when the final 1.0 release ships next week, you'll be able to change the address using SWFAddress.setValue('/portfolio'); In order to enable typical links to work from inside Flash you will probably need to replace them automatically with an appropriate asfunction. I will provide such a sample if I find the time.
http://en.wikipedia.org/wiki/Deep_linking
I tried within flash and it works. I dont actually need to interact from HTML, but from textareas inside flash so I am happy now :)
But the issue I talked about in my previous post is not related to this, is just general behaviour of SWFAddress. Can you try what I explained in my previous post?
"a transparent support for Urchin/Analytics in the future."
Now that would just take it from awesome to perfekt :D
Thank you for your fast answer!!
I totally missed that one - now it works perfect!!
Super...
Niklas
Here are some examples:
http://www.fashionclinic.pt
http://www.fm.ul.pt
http://www.lpn.pt
http://www.hoteisreal.com
We tried a lot of ways to achieve these functionalities and the SWFAddress will be the next one!
Special thanks to Rostislav for providing the code to the Flash community! :D
<a href="/portfolio" onclick="SWFAddress.setValue(this.href);return false;">Portfolio</a>. Such links can be indexed by search engines and this is where the upcoming SWFAddress 1.0 will help. For HTML formatted content inside Flash you will need <a href="asfunction:SWFAddress.setValue,/portfolio" >Portfolio</a>
This is happening in firefox 2 and IE 6.
Anyway, the script rocks
Maybe a solution could be by creating that anchors in the DOM before writting the link into the addressbar? You will have to change how the link is shown (you can´t have a anchor called "#/portfolio/2" but you can one called "#portfolio_2".
Hope it makes sense...
Here is the URL i am trying it on and getting the blank pages in IE
http://staging.habitatintl.com
Thanks & Regards,
Simplify Team
http://drupal.org/project/swfaddress
Flash Web Designs - www.simplify.co.in
Thanks again.
Joe recently added Safari support for it.
I have been looking for a simple implementation like this for ages.
Thanks, works great now. I was also able to use Geoff's swfobject javascript kit instead of ExternalInterface so making this compatible with Flash 7 shouldn't be an issue
The HTML sample I've provided won't work with the current release candidate. I wanted to give the basic idea how it can happen, but actually the call should look like this:
<a href="/portfolio" onclick="SWFAddress.setValue(this.href.replace(new RegExp(protocol + '//' + hostname + '(:' + port + ')?'), '')); return false;">Portfolio</a>
If you can stand to try it, please get the code from the Subversion repository on Sourceforge.net.
@Marcelo
I've tried this approach and I've tested it now again, but with no success. I'm also experiencing a nasty bug with Opera that fails to execute the loadMovie() every time.
@Tim
I have missed this one, but it looks nice. SWFAddress was made originally for websites but then I thought that Flex support will be nice.
It works perfect in Firefox but the forward button doesn't work in IE - if I look in the history under forward button in IE it says "HTTP 404 not found". I don't consider myself to be good at AS so I do something wrong but I just can't figure what...
Take a look here...
http://widangdes.com/test/
Help would be appreciated...
Niklas
Try to copy all the files from one of the samples on a webserver or send me an URL where I can see the problem.
Flash Player 7 is not supported because of the ExternalInterface. Depending on the number of request such support can be added in the future.
@vn
There're strange issues with Opera, but I'm currently testing with the latest Flash Player 9 Update Beta and it seems that nothing fails.
This allows IE to use iframe content.
http://widangdes.com/test/swfobj_adress/swfaddress.html
It's required and used only by IE.
There is still an issue I have with Internet Explorer (in Firefox and Safari works). If you go to your example, you click on contact and then you go and manually edit the URL in the address and change the last part "contact" for let say "about" you will see that the page does not actually change. I suppose the issue is that changing a anchor link does not fire the SWF funtions to make Flash aware that the url has changed, and if you then start clicking around on the flash links, flash gets aware and things work, but the url does not change anymore...
There is also another weird error. If you do the same with Firefox and after some clickings around, when you try to close the window you get and alert message with the url, and sometimes also a warning message saying that the script is trying to change the domain...
I suppose that if the user uses the application the "normal" way then he will not suffer these issues, but when debugging the application, as a programmer, is very annoying...
Thanks again for the examples.
Cheers
You who claimed to have narrowed it down, what is the problem? Is it possible to make a workaround?
I am using it successfully, but I have a question. I dont know if is a bug or just my wrong idea. I am able to fire refresh of the page by doing SWFAddress.setValue('/portfolio');
And that works fine. I wanted to do something else, in the same page where my flash is I would like to have an html link like:
Go to portfolio. In firefox this technique works, the page moves to portfolio, but in Internet Explorer it does not seems to realize that the url has changed.
I have this example in http://synthesys.csic.es/temp/test/
Being able to use it this way is really cool because then inside textareas in my flash that are loaded from xml I can very easily create links that trigger loading of movies... It actually makes developing flash similar to simple HTML (I am a new flash user and I still tend to think HTML).
Do you have any idea how to force Internet Explorer to "communicate" with flash when the url has changed like this?
Thanks in advance.
Sounds a bit like the opera bug, any ideas on what to do?
you can see the site at www.valhallaconquers.com/test
Manual changes of the hash part of the address lead to unexpected results and I think that this a problem of every implementation that uses this approach.
I can't tell you much about the Firefox domain issue because I can't reproduce it. Probably it can be caused by mixed usage of addresses like http://domain.com and http://www.domain.com.
I'm glad that you were able to make it work. An alternative to the ExternalInterface is being considered. I'm also planning to add a transparent support for Urchin/Analytics in the future.