Assemble a Nifty Twitter Widget using Flash and the Twitter API

May 8th in Screencasts, Widgets by Shane Johnson

Flash will work neatly in combination with the Twitter API to create a Twitter widget for any webpage. Follow Shane Johnson (@ultravisual) as he demonstrates building an interface, pulling in specific XML data and tackling cross-domain policy issues..

PG

Author: Shane Johnson

Originally from a fine art background, it took me a while to get in to the world of digital media, but now that I have, Flash has become my tool of choice. I currently work as a freelance flash designer developer, amongst other things, and strive to create engaging and creative applications for the web.

View Screencast

Get the Flash Player to see this player.

Enjoy this Post?

We'd love your vote!

User Comments

( ADD YOURS )
  1. PG

    wink May 8th

    Nifty, yes… Ugly, yes…

    ( Reply )
  2. PG

    Dario Gutierrez May 8th

    Interesting API, actually I’m developing a similar application like yours. Great tutorial.

    ( Reply )
  3. PG

    Diego SA May 8th

    Yes, it’s nifty, but it need to be improved… I mean, it doesn’t have a good face, you know?
    But it’s useful for a flash designer’s website.

    ( Reply )
  4. PG

    samBrown May 8th

    nice tutorial, thanks for the post

    ( Reply )
  5. PG

    Franky May 8th

    Legit. I love it

    ( Reply )
  6. PG

    karthikeyan vj May 8th

    to avoid the cursor changing on text area….

    textBox.mouseChildren = false;

    ( Reply )
  7. PG

    CgBaran Tuts May 9th

    Great tutorial thanks

    ( Reply )
  8. PG

    backcountrygen May 9th

    This is actually what I was looking for. It works great. Thanks

    ( Reply )
  9. PG

    Clemente G May 9th

    Cool Tut

    ( Reply )
  10. PG

    Chatton May 10th

    that’s good to have tutorials showing us how to use the document class!
    I’d love more about that, and how to link AS files with the document class, how to organize them and so on..

    Really good tutorial to me since i’m learning AS3 on my own, keep up the good work pal

    ( Reply )
  11. PG

    ctsf May 20th

    Your tut is awesome. I’m far from a programmer and your explanations for customization are fantastic. With a little luck I can make it work. Thanks so much

    ( Reply )
  12. PG

    Overtrack May 22nd

    This is a realy nice tutorial !
    Nonetheless, i have this error : Warning: stream_get_contents() expects parameter 1 to be resource, boolean given in /homez.184/overlutz/www/twitFeed.php on line 7

    Any idea?

    ( Reply )
    1. PG

      Overtrack May 23rd

      Hey it’s me again ! I just tested the fopen() with some other url and that works fine. It’s just with Twitter that this doesn’t work. I don’t understand…

      ( Reply )
      1. PG

        vector June 16th

        Also getting this error. Any help would be appreciated.

      2. PG

        vector June 17th

        I had someone that knows php way more than I do look at this error. Apparently there is a php security setting on your server that you can adjust, something about ini, that will allow for this to work.

        As you can see I have no idea what i’m talking about with php but he put it on his server and it worked fine.

        just fyi

  13. PG

    Overtrack May 24th

    Hello again,

    I now know what the problem is and maybe some of you will have the same…

    Twitter allows a maximum of 100 requests per hour and per IP. If your website is hosted on a mutualized hosting, that means that you and thousand of websites are sharing the same IP.

    That means that many requests can be send to Twitter in a short range of time.

    For exemple, on my mutualized hosting, the 100 requests are exeeded in less than 60 seconds.

    Do you think there is another way without send a request to Twitter for this tutorial?

    PS : Forgive me for my bad english.

    ( Reply )
  14. PG

    Siniestro May 27th

    Using this widget on a company site that uses a fancy dancy CMS and it contacts twitter but never ends up retrieving any tweets to populate the text boxes… any suggestions????

    ( Reply )
  15. PG

    socal May 28th

    i can’t get this widget to work. i loaded it to my site along with all the other files after i edited them. none of the tweets get pulled into the widget, but the follow me button works. any ideas?

    ( Reply )
  16. PG

    Shane Johnson May 29th

    Hi Guys,

    Any one who is having problems if you send me your files and I’ll have a little look and see whats wrong…

    Shane

    ( Reply )
    1. PG

      Michelle May 29th

      Hi Shane,

      I’m trying to use your method here but in 4 instances of a dynamic text box (not a text field component as you’ve used in your tutorial) – I can’t get it to work – any idea what could be wrong/different?

      ( Reply )
      1. PG

        Shane Johnson June 3rd

        Hi Michelle,

        With a dynamic text field, as long as they are named the same way as the text box I used in this tutorial, you would just need to do:

        box[i].text = “twitter xml data here”;

        Any more probs please email me more info.

        Shane

    2. PG

      HORCRUXES June 12th

      Hi Shane,

      It took me a lot of time figuring out the errors and somehow I manage to fix those mistype/mispelled and such, but I do have a problem of not showing anything on the 4 box. and I recieve this output:

      Error opening URL ‘http://twitter.com/statuses/user_timeline.xml?screen_name=HORCRUXES’
      Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: http://twitter.com/statuses/user_timeline.xml?screen_name=HORCRUXES
      at Twitter_Main/initTwit()
      at Twitter_Main()
      I
      First of I have no knowlege of ActionScript cause we haven’t learn yet.lol. I please you to help me cause this tutorial is addictive.
      Thanks

      ( Reply )
    3. PG

      Alejandro July 22nd

      hi shane, I have some problems with te action spcript,

      LINE 54
      1046: Type was not found or was not a compile-time constant: Event.

      CAN YOU HELP ME?????

      THANKS…

      ( Reply )
    4. PG

      brothergreg October 21st

      Please shane, what is your email add…

      ( Reply )
  17. PG

    Ray May 29th

    Hi shane, ive just emailed you my files

    ( Reply )
  18. PG

    Dimitree June 1st

    How can I change the size of text in textarea?

    ( Reply )
    1. PG

      Shane Johnson June 3rd

      Yep just change the font and size by adjusting the proerties of the textarea in flash.

      Shane

      ( Reply )
  19. PG

    bizzau June 12th

    can this be used as a module in joomla?

    ( Reply )
  20. PG

    e11world June 15th

    I wonder if you have time to create an AS2 version of this? I still haven’t migrated yet (I’m sure many haven’t too).

    ( Reply )
  21. PG

    Keith June 21st

    Great tut, but when I run my swf I get the following errors:

    TypeError: Error #2007: Parameter text must be non-null.
    at flash.text::TextField/replaceText()
    at flash.text::TextField/appendText()
    at fl.controls::TextArea/appendText()
    at Twitter_Main/loaded()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    I have also had to modify some settings of the flash player to allow access to the localhost (testing this locally first before deploying) so will everyone who views the live site have to do the same?

    I am completely new to flash so sorry if there is an obvious fix. I actually stumbled on your tut trying to find a way of embedding the twitter widget into my flash site.

    ( Reply )
  22. PG

    philip July 2nd

    Hello,

    I’d also like to thank you for a great script.

    However, I’m running into a problem with the PHP script side of things. Apparently the function stream_get_contents is only for PHP5. I don’t have the back-end info for the site I’m currently working on, but I’d guess it’s PHP4.

    Is there any PHP4 workaround for the stream_get_contents? Or am I missing something else?

    many thanks,
    philip

    ( Reply )
  23. PG

    Bob July 29th

    This tutorial is missing key steps in order to successfully replicate.

    If it wasn’t, 1/2 the comments above would not be present.

    ( Reply )
  24. PG

    Sarah Sullivan August 12th

    Terrible, terrible, terrible.

    Come on—the owners of this site HAVE to enact some form of quality control. This does not work. Download his source—it’s missing vital pieces of scripting for this to even come close to functioning.

    2/3 of this awful tutorial is devoted to his pink button gradients.

    Shame.

    Post RELEVANT, COMPLETE, and USEFUL tutorials if you want people to return to your website, and recommend it to others.

    Epic fail.

    ( Reply )
  25. PG

    June August 24th

    has anyone gotten this to work? I think I am having crossdomain.xml issues.
    Can someone shed some light here? I thought I correctly put the crossdomain file in the root folder..but nothing..

    ( Reply )
  26. PG

    June August 24th

    I get this error? Can someone help?

    TypeError: Error #1088: The markup in the document following the root element must be well-formed.
    at Twitter_Main/loaded()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    ( Reply )
  27. PG

    Chris September 11th

    got this working, thanks for the tweet tute… i was wondering how you could extend this to bring back only items tagged with the # hashmark as in search or retweet… any thoughts?

    Thanks!

    ( Reply )
  28. PG

    phatcafer September 14th

    there’s so many “mad flash professors” out there. actually few of them are able to explain as3. this tutorial can re-encourage lost flashers to a certain extend.

    well done.
    i like your accent.

    ( Reply )
  29. PG

    Brothergreg October 21st

    Hello, I search for hours to find this, thanks, I have one problem I hope you will help me out with. When I test the movie from flashcs4 itself it works and pulls the feed I want, yet when I try to play the swf file from the saved folder, or upload them to my server the text aera’s remain blank…please help

    ( Reply )
  30. PG

    MSFX November 4th

    i’d recommend using the Proxy script found at :

    http://www.republicofcode.com/tutorials/flash/twitter_widget/3.php

    This is a far more secure method…

    ( Reply )
  1. Arrow
    Gravatar

    Your Name
    November 4th