forked from: forked from: Flickrのsetを利用してみる
Flickrのsetを利用してみる
http://www.flickr.com/photos/38149748@N03/sets/72157621937806331/
...
@author umhr
/**
* Copyright sinketu ( http://wonderfl.net/user/sinketu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/pORH
*/
// forked from aass's forked from: Flickrのsetを利用してみる
// forked from umhr's Flickrのsetを利用してみる
/*
* Flickrのsetを利用してみる
* http://www.flickr.com/photos/38149748@N03/sets/72157621937806331/
* */
package {
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.DropShadowFilter;
import flash.net.navigateToURL;
import flash.net.URLLoader;
import flash.net.URLRequest;
/**
* ...
* @author umhr
*/
public class Main extends Sprite {
public function Main():void {
//ドキュメントルートのcrossdomain.xml(http://api.flickr.com/crossdomain.xml)で
//許可を与えているので、特に指定しなくても自動的に許可を取ってくる。
var myLoader:URLLoader = new URLLoader();
myLoader.addEventListener (Event.COMPLETE, COMPLETE);
//http://www.flickr.com/photos/38149748@N03/sets/72157621937806331/のRSS Feedを読み込む
myLoader.load(new URLRequest("http://api.flickr.com/services/feeds/photoset.gne?set=72157621937806331&nsid=38149748@N03&lang=en-us"));
}
private function COMPLETE(e:Event):void {
var myXML:XML = new XML(e.currentTarget.data);
default xml namespace = new Namespace("http://www.w3.org/2005/Atom");
var entryLength:int = myXML.entry.length();
for (var i:int = 0; i < entryLength; i++) {
var imgURL:String = myXML.entry[i].link[1].@href;
var myLoader:Loader = new Loader();
myLoader.load(new URLRequest(imgURL));
myLoader.x = 25 + (i % 2) * 215;
myLoader.y = 25 + Math.floor(i / 2) * 215;
myLoader.filters = [new DropShadowFilter()];
myLoader.name = myXML.entry[i].link[0].@href;
addChildAt(myLoader, 0);
}
addEventListener(MouseEvent.CLICK, CLICK);
}
private function CLICK(e:MouseEvent):void {
//クリックされたら、ターゲットの名前(link先)を取得して、httpがついていたら遷移
var linkURL:String = e.target.name;
if (linkURL.indexOf("http") + 1) {
navigateToURL(new URLRequest(linkURL) );
}
}
}
}