Get $500+ of the best After Effects files, video templates and music for only $20!
videos

Assemble a Nifty Twitter Widget using Flash and the Twitter API

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..

View Screencast

Get the Flash Player to see this player.

Tags: Videos
Add Comment

Discussion 46 Comments

  1. wink says:

    Nifty, yes… Ugly, yes…

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

  3. Diego SA says:

    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.

  4. samBrown says:

    nice tutorial, thanks for the post

  5. Franky says:

    Legit. I love it

  6. to avoid the cursor changing on text area….

    textBox.mouseChildren = false;

  7. CgBaran Tuts says:

    Great tutorial thanks

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

  9. Chatton says:

    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

  10. ctsf says:

    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

  11. Overtrack says:

    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?

    • Overtrack says:

      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…

      • vector says:

        Also getting this error. Any help would be appreciated.

      • vector says:

        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

  12. Overtrack says:

    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.

  13. Siniestro says:

    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????

  14. socal says:

    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?

  15. 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

    • Michelle says:

      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?

      • 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

    • HORCRUXES says:

      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

    • Alejandro says:

      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…

    • brothergreg says:

      Please shane, what is your email add…

  16. Ray says:

    Hi shane, ive just emailed you my files

  17. Dimitree says:

    How can I change the size of text in textarea?

  18. bizzau says:

    can this be used as a module in joomla?

  19. e11world says:

    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).

  20. Keith says:

    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.

  21. philip says:

    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

  22. Bob says:

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

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

  23. Sarah Sullivan says:

    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.

  24. June says:

    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..

  25. June says:

    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()

  26. Chris says:

    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!

  27. phatcafer says:

    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.

  28. Brothergreg says:

    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

  29. MSFX says:

    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…

  30. penclick says:

    will this widget work on myspace?

  31. Bruce says:

    Hi Shane, thanks for this tutorial. I’m having an issue and I think it is CS4.

    I get this error:

    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()

    As long as I dont try to save it, it works. CS4 allows me to save it as CS3, but when I do,
    I get the 1088 error that I think is a XML deal. I can send yours to the server and it works
    great. It’s killing me, cause I know it is something small. I have 8 on another machine, but
    I dont rem. if it stops at AS2. Any help would be greatly appreciated! This is way cool.

  32. Joe Shock says:

    Great stuff! Exactly what I needed; thanks!

    -joeshock

  33. Very useful widget. I used it in a website for a VIP client, and would like to mention here that Shane Johnson, the author of this tutorial, was extremely helpful in implementing it and demonsrated great knowledge of Flash and PHP. Thank you Shane!

  34. Ron Burch says:

    Hey Shane,

    How would I modify the code so the hyperlinks in the message are active? Thanks for the awesome tutorial!

    Ron Burch

  35. Brandon Anderson says:

    Worked great for me! Thanks!

  36. lock says:

    In the loaded function, why have you added the complete listener again???

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.