Actionscript:
-
[SWF(width = 800, height=600, frameRate=15)]
-
-
var littleTxt:TextField = TextField(addChild(new TextField()));
-
with (littleTxt){
-
defaultTextFormat = new TextFormat("_sans", 10);
-
width = stage.stageWidth-20;
-
height = stage.stageHeight-20;
-
multiline = true;
-
wordWrap = true;
-
text ="";
-
textColor = 0x444444;
-
selectable = false;
-
x = y = 10;
-
}
-
-
var txt:TextField = TextField(addChild(new TextField()));
-
with (txt){
-
defaultTextFormat = new TextFormat("_sans", 90);
-
autoSize = "center";
-
x = 0
-
y = stage.stageHeight / 2 - 61
-
width = stage.stageWidth;
-
selectable = false;
-
text = "loading";
-
}
-
-
var selectWords:Array = [];
-
addEventListener(Event.ENTER_FRAME, onLoop);
-
function onLoop(evt:Event):void {
-
if (selectWords.length> 0){
-
var word:String = selectWords[int(Math.random() * selectWords.length)];
-
txt.text = word;
-
littleTxt.appendText(word+" ");
-
}
-
}
-
-
var loader:URLLoader = new URLLoader();
-
var req:URLRequest = new URLRequest("http://search.twitter.com/search.atom");
-
var vars:URLVariables = new URLVariables();
-
vars.q = "i want";
-
// results per page
-
vars.rpp = "50";
-
vars.page = 1;
-
vars.lang = "en";
-
-
req.data = vars;
-
req.method = URLRequestMethod.POST;
-
loader.load(req);
-
loader.addEventListener(Event.COMPLETE, onLoaded);
-
function onLoaded(evt:Event):void{
-
var searchData:XML = new XML(loader.data);
-
var atom:Namespace = searchData.namespace("");
-
default xml namespace = atom;
-
var titles:String = "";
-
for each(var entry:XML in searchData.entry){
-
titles += entry.title.toString();
-
}
-
var index:int = 0;
-
var words:Array = titles.split(" ");
-
for (var i:int = 0; i<words.length; i++){
-
// exclude a few things
-
if (words[i].match(/RT|\@|\#|http/g).length == 0){
-
selectWords[index++] = words[i];
-
}
-
}
-
}
This snippet searches twitter for the phrase "I want" and then displays the results randomly word by word in a somewhat hypnotic way.