MandalaTV
Personal and Professional Blog of Rich Hauck

Sharing SWFAddress links with Facebook

by: Rich Hauck

Just discovered that Facebook’s link-sharing API doesn’t like links that aren’t URL encoded. This means that in cases where SWFAddress is used you’ll get funky results due to the necessary hashtag (#).

The solution is to use encodeURIComponent(), which can be found in Javascript, and conveniently as a top-level function in Actionscript 3.

So links can be shared in Actionscript via:

var url:String = "http://www.facebook.com/sharer.php?u=" + encodeURIComponent("http://www.mysite.com/#/whateva");
var request:URLRequest = new URLRequest(url);

UPDATE: Actually, it wasn’t very friendly with this, either, so I ended up using bit.ly’s API to shortcode the URL before passing it to Facebook.


Leave a Reply

Your email address will not be published. Required fields are marked *

About Rich Hauck

Rich Hauck

I'm a creative technologist at Hauck Interactive, Inc. and an adjunct instructor at HACC. I live in Harrisburg, Pa. with my wife and three boys. I enjoy good coffee, Trappist beers, Orioles baseball, and good design.


Archives