Adding links to Facebook and Twitter in Flash ActionScript 3

Here’s a shortcut that might help some folks out for creating links for status updates to Facebook and Twitter from within your Flash ActionScript 3 projects. For the simplicity of this blog post, I’m explaining this example in relation to buttons you have created in Flash and are residing on the stage:

  • Create your button objects in Flash, drag them to the stage and give them an instance name (in this example, I’m using “btn_twitter” and “btn_facebook”).
  • Add the following actionscript below to post a status message to Twitter.com:

MC_connect.btn_twitter.addEventListener(MouseEvent.CLICK, loadTwitter);
function loadTwitter(e:MouseEvent):void {
navigateToURL(new URLRequest(“http://twitter.com/home?status=Check out Itanji, L.L.C. for your web and rich Internet Application Development Needs! www.itanjillc.com“));

  • Add the following ActionScript below to post a status message to Facebook (note: you need to URL-encode u- and t-parameter):

MC_connect.btn_facebook.addEventListener(MouseEvent.CLICK, loadFacebook);
function loadFacebook(e:MouseEvent):void {
var fbURL:String = “http://www.facebook.com/sharer.php?u=” + encodeURIComponent(“http://www.itanjillc.com“) + “&t=” + encodeURIComponent(“Check out Itanji, L.L.C. for your web and rich Internet Application Development Needs! www.itanjillc.com”);
navigateToURL(new URLRequest(fbURL));
// The URL to Facebook should look like this:
// http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.itanjillc.com%2F%3Fp%3D82&t=Check+out+Itanji,+L.L.C.+for+your+web+and+rich+Internet+Application+Development+Needs!+www.itanjillc.com

Hope this helps some folks out there implementing Twitter and Facebook links in their Flash/AS3 applications!

Flash Dynamic Text Fields Not Working After I Upgraded to CS5 Professional.

After upgrading to Adobe Flash CS5 Professional, I found that some of my applications were not functioning properly, specifically with dynamic text fields that were displaying loaded data. I thought it was silly to try embedding fonts to solve the problem, but oddly enough, doing so resolved the issue.