In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

青空文庫のテキストを取得

http://pipes.yahoo.com/pipes/pipe.info?_id=68fa588146242e845cbac5f0ce3804a2
* 
* http://www.aozora.gr.jp/cards/000879/files/3814_27290.html
*
Get Adobe Flash player
by umhr 16 Dec 2009
/**
 * Copyright umhr ( http://wonderfl.net/user/umhr )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/v9UW
 */

/*
 * 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, onCompleteJSON);
			//YahooPipesの汎用feedPage
			var jsonURL:String = "http://pipes.yahooapis.com/pipes/pipe.run?_id=68fa588146242e845cbac5f0ce3804a2&_render=json&url=";
			//encodeURIComponentでエスケープして、feedProxyにくっつける。
			jsonURL += encodeURIComponent("http://www.aozora.gr.jp/cards/000879/files/3814_27290.html");
			myURLLoader.load(new URLRequest(jsonURL));
		}
           
		private function onCompleteJSON(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);
		}
	}
}