特定ユーザーのつぶやき表示テスト(2)
forked from Twitterの特定ユーザーのつぶやき表示テスト (diff: 57)
ActionScript3 source code
/**
* Copyright 7kamura ( http://wonderfl.net/user/7kamura )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/gSwZ
*/
// forked from 7kamura's Twitterの特定ユーザーのつぶやき表示テスト
package {
import flash.display.*;
import flash.text.*;
import flash.net.*;
import flash.events.*;
public class FlashTest extends Sprite {
// private var URLString:String = "http://pipes.yahooapis.com/pipes/pipe.run?_id=be6a7d91033f356879ac731a0d5cb041&_render=rss";
private var URLString:String = "http://swordmaster.sitemix.jp/crossdomain-proxy.php?url=http://twitter.com/statuses/user_timeline.xml?screen_name=gakuweb";
// private var URLString:String = "http://swordmaster.sitemix.jp/crossdomain-proxy.php?url=http://twitter.com/statuses/public_timeline.xml";
// private var URLString:String = "http://swordmaster.sitemix.jp/crossdomain-proxy.php?url=http://twitter.com/statuses/friends_timeline.xml?screen_name=7kamura";
private var rssURL:URLRequest;
private var rssLoader:URLLoader;
private var tweetsXML:XMLList;
private var tfld:TextField;
public function FlashTest() {
tfld = new TextField();
tfld.autoSize = TextFieldAutoSize.LEFT;
tfld.text = "test";
tfld.wordWrap = true;
tfld.multiline = true;
tfld.width = 300;
addChild(tfld);
getTweets();
}
private function getTweets():void {
rssURL = new URLRequest(URLString);
rssLoader = new URLLoader();
rssLoader.addEventListener(Event.COMPLETE, onLoadXML);
rssLoader.load(rssURL);
}
private function onLoadXML(e:Event):void {
tweetsXML = new XMLList(e.target.data);
var tweets:XMLList = tweetsXML.children();
var length:int = tweets.length();
var y:Number = 0;
var img_url:String;
var body:String;
var text:String = "";
tfld.text = tweets;
for(var i:int = 0; i<tweets.length(); i++) {
var tfld:TextField = new TextField();
body = tweets[i].text;
tfld.width = 465;
tfld.height = 100;
tfld.autoSize = TextFieldAutoSize.LEFT;
tfld.multiline = true;
tfld.wordWrap = true;
tfld.background = true;
tfld.backgroundColor = int("0x" + String(tweets[i].user.profile_sidebar_fill_color));
tfld.textColor = int("0x" + (tweets[i].user.profile_text_color));
img_url = tweets[i].user.profile_image_url;
if(img_url == "")
img_url = "http://s.twimg.com/a/1254440757/images/default_profile_mini.png";
tfld.htmlText = '<p><img src="' + img_url + '" />' + tweets[i].text + '</p>\n';
tfld.y += y;
y += Math.max(tfld.height, 60);
addChild(tfld);
}
}
}
}
