forked from: (3.5)青空文庫のテキストを取得
http://pipes.yahoo.com/pipes/pipe.info?_id=68fa588146242e845cbac5f0ce3804a2
*
* http://www.aozora.gr.jp/cards/000879/files/3814_27290.html
*
/**
* Copyright yoropan ( http://wonderfl.net/user/yoropan )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/pNbp
*/
// forked from umhr's (3.5)青空文庫のテキストを取得
/*
* http://pipes.yahoo.com/pipes/pipe.info?_id=68fa588146242e845cbac5f0ce3804a2
*
* http://www.aozora.gr.jp/cards/000879/files/3814_27290.html
* */
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.net.navigateToURL;
import flash.text.TextField;
import com.adobe.serialization.json.JSON;
/**
* ...
* @author umhr
*/
[SWF(backgroundColor="0xF0F8FF")]
public class Main extends Sprite
{
public function Main():void
{
var myURLLoader:URLLoader = new URLLoader();
myURLLoader.addEventListener (Event.COMPLETE, COMPLETE);
//YahooPipesの汎用feedPage
var URLstr:String = "http://pipes.yahooapis.com/pipes/pipe.run?_id=68fa588146242e845cbac5f0ce3804a2&_render=json&url=";
//encodeURIComponentでエスケープして、feedProxyにくっつける。
URLstr += encodeURIComponent("http://www.aozora.gr.jp/cards/000879/files/3814_27290.html");
myURLLoader.load(new URLRequest(URLstr));
}
private function COMPLETE(e:Event):void
{
//jsonとして受け取る
var json:Object = JSON.decode(e.target.data);
var jsonString:String = json.value.items[0].content;
//正規表現で不要なタグを削除
jsonString = jsonString.replace(/<r.>|<\/r.>|<ruby>|<\/ruby>/g, "");
//XML型にする
var bookXML:XML = new XML(jsonString);
//テキストフィールドを作りXMLを流し込む
var myTextField:TextField = new TextField();
myTextField.width = 465;
myTextField.height = 465;
myTextField.htmlText = bookXML;
myTextField.wordWrap = true;
addChild(myTextField);
}
}
}