Twitter, Hash Tags, Flash and URLEncoding

Recently while working on a project I had to create a way for users to Tweet a message from the application that included a hash tag in the message. To achieve this functionality, we can use a Twitter URL and pass it the message we wish to display.

We can use navigateToURL to load the url. A URLRequest automatically URL encodes the variables when it is sent, but however will not work with hash tags. Not good!

Hope is not lost however, as within Flash there is however a top level escape() function that will URLEncode a string. We can use this to help with our URLRequest because after manually typing the URL we can simply append the escaped information onto the end of it.

navigateToURL( new URLRequest(""+ escape("Hey, thanks GrindheadGames! #grindheadgames")),"_blank");

This will allow you to post messages to Twitter that includes special characters like hash tags.

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditShare on StumbleUponShare on TumblrEmail this to someone

Leave a Reply

Your email address will not be published.