Friday,
18 May 2007
SWFAddress bad practices
As the number of SWFAddress powered sites grows I often see problems caused by poor implementations or lack of information. Here is a list of the top 5 practices which should be avoided:
- Usage of getURL() for user tracking, statistics and popups
- While this is a standard Flash functionality used for years, the combination with ExternalInterface introduces a critical bug with Internet Explorer. The resolution is to use ExternalInterface for every JavaScript call. SWFAddress 2.0 will help you with some predefined methods for popups and blank window links.
- Homepage address values like '#Home' or '#/root'
- Such address values are not needed and should be replaced by SWFAddress.setValue('/'). The usage of http://domain.com/#home creates an unneeded history entry when http://domain.com is opened.
- Address values naming using camelCase or other forms of custom convention
- SWFAddress samples clearly define the best naming convention for deep links. Web addresses are case insensitive and the standard is lower case. For readability and Google SEO compatibility reasons the convention 'my-deep-link' is more appropriate than 'myDeepLink' or 'My_deep_link'. The format http://domain.com/#/my-deep-link/?param=value is the only one fully compatible with the SWFAddress SEO rewriting.
- Including SWFAddress before the TITLE tag
- SWFAddress contains a fix for Internet Explorer and URLs which contain anchors. In order to benefit from it the title tag should be printed before the swfaddress.js include.
- Duplication of navigation logic
- Integration of SWFAddress into a legacy code may require the following implementation: For brand new projects, the best way to organize your code looks like this:
Update: The post has been updated for SWFAddress 2.0.
Posted by Rostislav at 2:15 PM in SWFAddress
Comments:
How can I find out if eventIsCalledFromTheBrowser?
So that it executes only then?
Thanks in advance.
Yup, I have the same issue - I'd need to somehow differentiate the setValue() calls from Flash and from the Browser.
As far as I can see, setValue() only supports 1 method. And it's called equally from Flash and from the JavaScript.
Cheers.
I too would like to know how to differentiate the source of the setValue event dispatch. Some boolean like "eventFromBrowser" would be adequate.
Althought I appreciate the whole SEO thing, using "-" within Actionscript is just a bit of a pain since it's an operator. Any suggestions for this issue?
@Ryan
The hyphen is good for indexing because Google treats it like a space. Since it's a string so far I haven't seen any problems with it. If you want to map deep links to instance names then probably you can replace it with an underscore?
For some reason whenever I'm navigating through selections quickly using firefox on my mac. There is a strange behavior where the page navigation will bounce undesirably between the two pages i clicked on before settling on the appropriate page. I thought it was my implementation of navigation logic, but this is also apparent in the CS3 sample listed on this site. Of course it only occurs when clicking back and forth quicktly.
So no one has solution for finding out whether the onChange was fired from the browser originally or not?
@Tim
It's easy to implement in your code and will probably become a new feature in the next SWFAddress release.