TinyURL code snippet for Javascript / Flash applications

We’ve been very busy this year with over a dozen new branded applications developed for multiple platforms. I wanted to take the chance to share a code snippet from a recent project that will benefit developers that want to shorten URLs at runtime:

var tinyURL:LoadVars = new LoadVars();
tinyURL.onLoad = function(){
var newURL:String = tinyURL.toString();
newURL = newURL.split('=&onLoad=%5Btype%20Function%5D').join('');
newURL = unescape(newURL);
trace('Tiny url response: '+newURL);
};
tinyURL.load('http://tinyurl.com/api-create.php?url=http://flash-widgets.com');

It’s that simple. The same can be done loading via XML.

Take care,
Kirk Ballou
CEO / Chief Architect
Flash Widgets, LLC