forked from: twitterなうサーチ
forked from twitterなうサーチ (diff: 1)
ActionScript3 source code
/**
* Copyright GiulioGrasso_NL ( http://wonderfl.net/user/GiulioGrasso_NL )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/kmD3
*/
// forked from kuma360's twitterなうサーチ
package {
import com.bit101.components.PushButton;
import flash.events.IOErrorEvent;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.navigateToURL;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.utils.escapeMultiByte;
[SWF(width = "465", height = "465", frameRate = "30", backgroundColor = "#DDDDDD")]
public class Main extends Sprite {
public function Main() {
//////////////////////////////////////
default xml namespace = new Namespace ( "http://www.w3.org/2005/Atom" ) ;
//////////////////////////////////////
var TF:TextField = new TextField ( ) ;
TF.x = 0 ;
TF.y = 0 ;
TF.width = 465 ;
TF.height = 400 ;
//////////////////////////////////////
var A:URLLoader = new URLLoader ( ) ;
//////////////////////////////////////
A.addEventListener (
Event.COMPLETE,
function ( e:Event ) :void {
TF.text = "";
var myXML:XML = new XML ( e.currentTarget.data ) ;
var L:int = myXML.entry.length();
var I:int ;
var N:Array = [];
for ( I = 0; I < L ; I++ ) {
N.push(I);
}
N.sort (
function ( ) :int {
return Math.random ( ) > 0.5 ? 1 : - 1 ;
}
);
var J:int = L > 9 ? 9 : L ;
for ( I = 0; I < J ; I++ ) {
TF.appendText ( myXML.entry[N[I]].author.name ) ;
TF.appendText ( "\n" ) ;
TF.appendText ( myXML.entry[N[I]].title ) ;
TF.appendText ( "\n\n" ) ;
}
}
);
//////////////////////////////////////
A.addEventListener (
IOErrorEvent.IO_ERROR,
function (e:Event):void {
trace(e.type);
}
);
var xmlURL:String ;
xmlURL = "http://search.twitter.com/search.atom?q=";
xmlURL += encodeURIComponent ( "なう" ) ;
xmlURL += "&rpp=1000&test=" + Math.random;
A.load ( new URLRequest ( xmlURL ) ) ;
//////////////////////////////////////
new PushButton (
this,
10,
465 - 30 ,
"more",
function ( e:MouseEvent) :void {
A.load ( new URLRequest ( xmlURL ) ) ;
}
);
//////////////////////////////////////
new PushButton(
this,
100,
465 - 30 ,
"Tweet now",
function(e:MouseEvent):void {
navigateToURL(new URLRequest("http://twitter.com/home/?status="
+ escapeMultiByte("http://wonderfl.net/c/4pmX なう")
));
}
);
addChild ( TF ) ;
}
}
}