(3.3)YahooPipesでfeedProxy(首相官邸ホームページ)
forked from (3.1)YahooPipesでfeedProxy(wgn) (diff: 8)
http://www.kantei.go.jp/index-j2.rdf *
ActionScript3 source code
/**
* Copyright umhr ( http://wonderfl.net/user/umhr )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/3ZW7
*/
/*
*
* http://www.kantei.go.jp/index-j2.rdf
* */
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.net.navigateToURL;
import flash.text.TextField;
/**
* ...
* @author umhr
*/
[SWF(backgroundColor="0xC4BFAB")]
public class Main extends Sprite
{
public function Main():void
{
var myURLLoader:URLLoader = new URLLoader();
myURLLoader.addEventListener (Event.COMPLETE, COMPLETE);
//YahooPipesの汎用feedProxy
var URLstr:String = "http://pipes.yahooapis.com/pipes/pipe.run?_id=f4f6c98189a88373b9bfd4fe6128c018&_render=rss&url=";
//encodeURIComponentでエスケープして、feedProxyにくっつける。
URLstr += encodeURIComponent("http://www.kantei.go.jp/index-j2.rdf");
myURLLoader.load(new URLRequest(URLstr));
}
private function COMPLETE(e:Event):void
{
var myXML:XML = new XML(e.currentTarget.data);
var title:TextField = new TextField();
title.background = true;
title.backgroundColor = 0x2B0F0F;
title.text = "首相官邸ホームページ";
title.textColor = 0xFFFFFF;
title.width = 461;
title.height = 18;
title.x = 2;
addChild(title);
//要素を取り出して、textFieldを作りならべている。
var itemLength:int = myXML.channel.item.length();
for (var i:int = 0; i < itemLength; i++) {
var htmldata:String = "";
htmldata += "<a href='" + myXML.channel.item[i].link + "' target='_blank'>";
htmldata += "Title:" + myXML.channel.item[i].title + "\n";
htmldata += "Link:" + myXML.channel.item[i].link + "\n";
htmldata += "PubDate:" + myXML.channel.item[i].pubDate;
htmldata += "</a>";
var tf:TextField = new TextField();
tf.autoSize = "left";
tf.background = true;
tf.border = true;
tf.borderColor = 0x2B0F0F;
tf.htmlText = htmldata;
tf.width = 460;
tf.wordWrap = true;
tf.x = 2;
tf.y = this.height + 2;
addChild(tf);
}
}
}
}
