flickr+Yahoo!Pipes(xml)3
forked from flickr+Yahoo!Pipes(xml)2 (diff: 18)
http://pipes.yahoo.com/pipes/pipe.info?_id=bd89377e6444cfe6083bad4904c60b79 http://d.hatena.ne.jp/ku-KiKi/20090524/p1
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/zGy3
*/
/*
http://pipes.yahoo.com/pipes/pipe.info?_id=bd89377e6444cfe6083bad4904c60b79
http://d.hatena.ne.jp/ku-KiKi/20090524/p1
*/
package {
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import com.adobe.serialization.json.JSONDecoder;
public class Main extends Sprite {
private var ns:Namespace;
public function Main() {
var myURLLoader:URLLoader = new URLLoader();
myURLLoader.addEventListener(Event.COMPLETE, onComplete);
myURLLoader.load(new URLRequest("http://pipes.yahooapis.com/pipes/pipe.run?_id=bd89377e6444cfe6083bad4904c60b79&_render=rss&loc=tokyo&num=20&q=flower"));
}
private function onComplete(e:Event):void {
var myXML:XML = new XML(e.currentTarget.data);
//default xml namespace = new Namespace("http://search.yahoo.com/mrss/");
//↑こちらの書き方も正しいけど、違う方法を試してみる。
//default xml namespace = myXML.namespace("media");
//や
//var myNs:Namespace = myXML.namespace("media");
//default xml namespace = myNs;
//↑だとほかの関数の呼び出しがあると、エラーが出る。
//なので
ns = myXML.namespace("media");
default xml namespace = ns;
//↑という書き方にする。nsをグローバル変数とする。
//【関連】http://d.hatena.ne.jp/ku-KiKi/20090524/p1
//【関連】http://kozy.heteml.jp/l4l/2008/07/as3xml.html
nextFunc();
for (var i:int = 0; i < 4; i++) {
var myLoader:Loader = new Loader();
myLoader.load(new URLRequest(myXML.channel.item[i].group.content.@url));
myLoader.x = myLoader.y = i*100;
addChild(myLoader);
}
}
private function nextFunc():void{}
}
}
