following viewer

wonderflにはユーザー同士がfollow(お気に入り)登録する機能があって、それが見れたりすると楽しいかなと思って作った。

2010/7/12追記:たぶんwonderfl側の仕様変更で動かなくなりました。スクレイピングの命ははかない。残念

wonderfl上のイベントで「アルゴリズムでエロスを表現してください。 公序良俗は守ってください。」に応募のつもりが締め切り過ぎてた…orz

(直球じゃない)エロスってなんだろうなと考えたときに、関係性のアンバランスさ危うさが源泉になるんじゃないかな、と思った。

wonderflにはユーザー同士がfollow(お気に入り)登録する機能があるが、互いにfollowしあってたり、一方通行だったりする様子が見えちゃうと、ちょっとドキドキする。

「あれ、この人たくさんfollowしているのに、俺はfollowされてない!」とかって、ちょっと内臓からにじみ出る感情だよね、、、。

と思ったんだけど、単なる「友達の輪!ビューア」になったような気も、、笑

位置によって、中央のユーザーとの関係がわかるんだけど、、、わかりづらいですね。
推測してください。それも含めてのアンバランスさ、ということで(逃げ)

「FULL SCREEN」での閲覧推奨

▼Wonderfl
http://wonderfl.net/code/134fad8e7157015beb0ebf1fd1de5a689c2ee92e

▼ActionScript AS3(FP10)
[sourcecode language=”as3″]

package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.geom.Matrix3D;
import flash.geom.Vector3D;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.net.navigateToURL;
import flash.net.URLRequest;

import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.tweens.ITween;

[SWF(backgroundColor="0x271010",width=465,height=465)]
public class Main extends Sprite
{
private var tf:TextField;
private var _api:API;
private var _canvas:Sprite;
private var _user:Vector.<Number>;
private var _posted:Vector.<Number>;
private var _frends:Vector.<Number>;
private var _following:Vector.<Number>;
private var _followers:Vector.<Number>;
private var _tempPosted:Vector.<Number> = new Vector.<Number>();
private var _tempFrends:Vector.<Number> = new Vector.<Number>();
private var _tempFollowing:Vector.<Number> = new Vector.<Number>();
private var _postedMatrix3D:Matrix3D;
private var _frendsMatrix3D:Matrix3D;
private var _followingMatrix3D:Matrix3D;
private var _globalMatrix3D:Matrix3D;
public function Main()
{
stage.scaleMode = "noScale";
this.addEventListener(MouseEvent.MOUSE_DOWN, atMouseDown);

_canvas = new Sprite();
_canvas.x = 465 / 2;
_canvas.y = 465 / 2;
this.addChild(_canvas);

//userListは↓から一部改変(followが極端に少ない人を削除)
//http://wonderfl.net/code/b62d136618e3a9c80163313634c9f6957f3773b9
var userList:Array = [ // fav>=50 @ 2009/11/16
"clockmaker","keim_at_Si","Saqoosha","tail_y","alumican_net","miyaoka","nutsu","sake","yd_niku","k3lab",
"Aquioux","makc3d","soundkitchen","k0rin","bkzen","psyark","keno42","nemu90kWw","uwi","shapevent",
"5ivestar","nitoyon","mrdoob","umhr","Nao_u","fumix","mtok","miniapp","HaraMakoto","coppieee",
"paq", "178ep3", "fladdict", "Hiiragi","yooKo","mash","9re","onedayitwillmake","beinteractive","a24",
"minon","demouth","ton","ABA","twistcube","yanbaka","rect","Murai","ll_koba_ll",
"naoto5959","knd","Kay","peko","northprint","hikipuro","enok","matsu4512","wanson",
"zahir","set0","cellfusion","abakane","seyself", "tkinjo","szktkhr","osamX","muta244","milkmidi",
"heriet","dubfrog","flashrod","nulldesign","TX_298","yonatan","katapad","enoeno",
"Nicolas","dizgid","k__","gyuque","yshu","TheCoolMuseum","poiasd",
"y_tti","coppieeee","munegon","matsumos","KinkumaDesign","ish_xxxx","cjcat2266","kappaLab","runouw","iong"];
var user:String = userList[Math.floor(userList.length * Math.random())];
_api = new API(user);
_api.atComp = atComp;
_api.play();
nowLoadings(user)
}
private function nowLoadings(name:String,targetSp:Sprite = null):void {
var shield:Sprite = new Sprite();
shield.graphics.beginFill(0x110000, 0.7);
shield.graphics.drawRect( -stage.stageWidth / 2, -stage.stageHeight / 2, stage.stageWidth, stage.stageHeight);
shield.graphics.endFill();
_canvas.addChild(shield);

var textY:int = 0;
var nowloadingsText:TextField = new TextField();
nowloadingsText.defaultTextFormat = new TextFormat("_sans", 12, 0xCC9999);
nowloadingsText.text = "Now loadings…";
nowloadingsText.autoSize = "left";
var txtBitmapData:BitmapData = new BitmapData(nowloadingsText.width, nowloadingsText.height, true, 0x000000);
txtBitmapData.draw(nowloadingsText);
var txtBitmap:Bitmap = new Bitmap(txtBitmapData);
txtBitmap.x = -txtBitmap.width / 2;
_canvas.addChild(txtBitmap);
var t0:ITween;
t0 = BetweenAS3.tween(txtBitmap, { alpha:0.5 }, { alpha:1 }, 0.1);
t0.stopOnComplete = false;
t0.play();
if(targetSp){
var tz:Number = targetSp.z;
targetSp.z = 0;
var bitmapData:BitmapData = new BitmapData(targetSp.width+2,targetSp.height+2,true,0x000000);
bitmapData.draw(targetSp);
targetSp.z = tz;
var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.scaleX = bitmap.scaleY = 2;
bitmap.x = -bitmap.width / 2;
bitmap.y = -bitmap.height / 2;
_canvas.addChild(bitmap);
textY = bitmap.height / 2;
txtBitmap.y = bitmap.y – txtBitmap.height;
var t:ITween;
t = BetweenAS3.tween(bitmap, { alpha:0.5 }, { alpha:1 }, 0.1);
t.stopOnComplete = false;
t.play();
}else {
txtBitmap.y = -txtBitmap.height;
}
var tf:TextField = new TextField();
tf.defaultTextFormat = new TextFormat("_sans", 10, 0xFFFFFF);
tf.text = name;
tf.autoSize = "left";
tf.x = -tf.width / 2;
tf.y = textY;
tf.selectable = false;
_canvas.addChild(tf);
}
private function atMouseDown(event:MouseEvent):void {
trace("atMouseDown",event.target.name)
if (event.target.name.substr(0,8) == "instance") {
return;
}else if(event.target.name.substr(0,20) == "http://wonderfl.net/") {
navigateToURL(new URLRequest(event.target.name), "_blank");
return;
}

nowLoadings(event.target.name,event.target as Sprite);

this.removeEventListener(Event.ENTER_FRAME, atEnterFrame);
_api = new API(event.target.name);
_api.atComp = atComp;
_api.play();
}
private function atComp():void {
while (_canvas.numChildren > 0) {
_canvas.removeChildAt(0);
}

_postedMatrix3D = new Matrix3D();
_frendsMatrix3D = new Matrix3D();
_followingMatrix3D = new Matrix3D();
_globalMatrix3D = new Matrix3D();
_globalMatrix3D.prependTranslation(0, 0, 100);

_user = new Vector.<Number>();
_user = Vector.<Number>([0, 0, 0]);
_canvas.addChild(_api.user.image);

var n:int;
n = _api.posted.length;
_posted = new Vector.<Number>();
for (var i:int = 0; i < n; i++) {
var num:Number = n / 2 – Math.abs(i – n / 2);
num /= (n / 2);
_posted = _posted.concat(Vector.<Number>([num*100 * Math.sin(Math.PI * 4 * i / n), (i – n / 2) * 50, num*100 * Math.cos(Math.PI * 4 * i / n)]));
_canvas.addChild(_api.posted[i].image);
}

n = _api.frends.length;
_frends = new Vector.<Number>();
for (i = 0; i < n; i++) {
_frends = _frends.concat(Vector.<Number>([150 * Math.sin(Math.PI * 2 * i / n), 0, 150 * Math.cos(Math.PI * 2 * i / n)]));
_canvas.addChild(_api.frends[i].image);
}

n = _api.following.length;
_following = new Vector.<Number>();
for (i = 0; i < n; i++) {
var num2:Number = (i < n / 2)? -1:1;
_following = _following.concat(Vector.<Number>([300 * Math.sin(Math.PI * 4 * i / n), num2*150, 300 * Math.cos(Math.PI * 4 * i / n)]));
_canvas.addChild(_api.following[i].image);
}

n = _api.followers.length;
_followers = new Vector.<Number>();
for (i = 0; i < n; i++) {
_followers = _followers.concat(Vector.<Number>([600 * Math.sin(Math.PI * 8 * i / n), (i – n / 2) * 1500/n, 600 * Math.cos(Math.PI * 8 * i / n)]));
_canvas.addChild(_api.followers[i].image);
}

this.addEventListener(Event.ENTER_FRAME, atEnterFrame);
}
private function atEnterFrame(event:Event):void {
var mx:Number = (stage.mouseX + (stage.stageWidth – 465) / 2) / stage.stageWidth-0.5;
mx = Math.min(Math.max(mx, -0.5), 0.5);

var my:Number = (stage.mouseY + (stage.stageHeight – 465) / 2) / stage.stageHeight-0.5;
my = Math.min(Math.max(my, -0.5), 0.5);
_globalMatrix3D.appendRotation(1,Vector3D.Y_AXIS);
_globalMatrix3D.appendRotation(0.1,Vector3D.X_AXIS);
_globalMatrix3D.prependRotation(mx,Vector3D.X_AXIS);
_globalMatrix3D.appendTranslation(0, 0, my);
animation();
}
private function animation():void {
_postedMatrix3D.appendRotation(2,Vector3D.Y_AXIS);
_postedMatrix3D.transformVectors(_posted, _tempPosted);
_frendsMatrix3D.appendRotation(1,Vector3D.Y_AXIS);
_frendsMatrix3D.transformVectors(_frends, _tempFrends);
_followingMatrix3D.appendRotation(0.5,Vector3D.Y_AXIS);
_followingMatrix3D.transformVectors(_following, _tempFollowing);
render();
}
private function render():void {
var n:int;
var i:int;
var vote:Vector.<Number> = new Vector.<Number>();
_globalMatrix3D.transformVectors(_user, vote);
_api.user.image.x = vote[0]-_api.user.image.width/2;
_api.user.image.y = vote[1]-_api.user.image.height/2;
_api.user.image.z = vote[2];

vote = new Vector.<Number>();
_globalMatrix3D.transformVectors(_tempPosted, vote);
n = _api.posted.length;
for (i = 0; i < n; i++) {
_api.posted[i].image.x = vote[i*3+0]-_api.posted[i].image.width/2;
_api.posted[i].image.y = vote[i*3+1]-_api.posted[i].image.height/2;
_api.posted[i].image.z = vote[i*3+2];
}
vote = new Vector.<Number>()
_globalMatrix3D.transformVectors(_tempFrends, vote);
n = _api.frends.length;
for (i = 0; i < n; i++) {
_api.frends[i].image.x = vote[i*3+0]-_api.frends[i].image.width/2;
_api.frends[i].image.y = vote[i*3+1]-_api.frends[i].image.height/2;
_api.frends[i].image.z = vote[i*3+2];
}
vote = new Vector.<Number>()
_globalMatrix3D.transformVectors(_tempFollowing, vote);
n = _api.following.length;
for (i = 0; i < n; i++) {
_api.following[i].image.x = vote[i*3+0]-_api.following[i].image.width/2;
_api.following[i].image.y = vote[i*3+1]-_api.following[i].image.height/2;
_api.following[i].image.z = vote[i*3+2];
}
vote = new Vector.<Number>()
_globalMatrix3D.transformVectors(_followers, vote);
n = _api.followers.length;
for (i = 0; i < n; i++) {
_api.followers[i].image.x = vote[i*3+0]-_api.followers[i].image.width/2;
_api.followers[i].image.y = vote[i*3+1]-_api.followers[i].image.height/2;
_api.followers[i].image.z = vote[i*3+2];
}
zSort();
}
private function zSort():void {
var n:int = _canvas.numChildren;
var array:Array = [];
var reference:Array = [];
for (var i:int = 0; i < n; i++) {
array[i] = _canvas.getChildAt(i).z;
reference[i] = _canvas.getChildAt(i);
}
var temp:Array = array.sort(Array.NUMERIC | Array.RETURNINDEXEDARRAY);
for (i = 0; i < n; i++) {
_canvas.setChildIndex(reference[temp[i]],0)
}
}
}
}

/*
* WonderflAPIで取得した結果を元に、
* Fileローダーで画像を取得して、素材をそろえる。
* */
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.filters.DropShadowFilter;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.text.TextField;
import flash.text.TextFormat;
class API {
private var _wonderflAPI:WonderflAPI;
private var _multiLoaderClass:MultiLoaderClass;
private var _userThumb:Array;
private var _followersThumb:Array;
private var _followingThumb:Array;
private var _frendsThumb:Array;
public var posted:Array;

public var followers:Array;
public var following:Array;
public var frends:Array;

public var user:Object;
public var atComp:Function = function():void{};
public function API(userName:String):void {
//初期化系
_multiLoaderClass = new MultiLoaderClass();
_wonderflAPI = new WonderflAPI(userName);
_userThumb = [];
_wonderflAPI.atUserComp = atUserComp;

}
public function play():void {
_wonderflAPI.loadUserData();
}
private function atUserComp():void{
var array:Array = [];
var n:int = _wonderflAPI.data.userCodes.length;
array.push("http://api."+String(_wonderflAPI.data.user.icon).substr(7));
for (var i:int = 0; i < n; i++) {
if(String(_wonderflAPI.data.userCodes[i].thumbnail).substr(0,19) == "http://wonderfl.net"){
array.push("http://api."+String(_wonderflAPI.data.userCodes[i].thumbnail).substr(7));
}else{
array.push(String(_wonderflAPI.data.userCodes[i].thumbnail));
}
}
_multiLoaderClass.isCheckPolicyFile = true;
_userThumb = _multiLoaderClass.setLoad(array,atImgComp);
}
private function atImgComp(errors:Array):void {
var n:int = _userThumb.length;
posted = [];
for (var i:int = 0; i < n; i++) {
if(_userThumb[i]){
var r:int = 20;
if(i == 0){
r = 50;
}
var bitmapData:BitmapData = new BitmapData(r * 2 , r * 2);
var w:int = _userThumb[i].width;
var h:int = _userThumb[i].height;
bitmapData.draw(_userThumb[i].content,new Matrix(r*2/w,0,0,r*2/h),null,null,null,true);
var sp:Sprite = new Sprite();
if (i == 0) {
sp.name = "http://wonderfl.net/user/" + _wonderflAPI.data.user.name;
var tf:TextField = new TextField();
tf.defaultTextFormat = new TextFormat("_sans", 12, 0xFFFFFF);
tf.text = _wonderflAPI.data.user.name;
tf.autoSize = "left";
var nameTagData:BitmapData = new BitmapData(tf.width+1, tf.height+1, true, 0xFF0000);
nameTagData.draw(tf);
}else {
sp.name = "http://wonderfl.net/code/" + _wonderflAPI.data.userCodes[i-1].id;
}
sp.graphics.beginBitmapFill(bitmapData, new Matrix(), false, true);
sp.graphics.drawCircle(r,r,r-1);
sp.graphics.endFill();
if (i == 0) {
sp.graphics.beginBitmapFill(nameTagData,new Matrix(1,0,0,1,(w-nameTagData.width)/2,h),false,true);
sp.graphics.drawRect((w-nameTagData.width)/2,h,nameTagData.width,20);
sp.graphics.endFill()
}
sp.buttonMode = true;
posted.push({"image":sp});
}
}
user = posted.shift();
_wonderflAPI.atFollowComp = atFollowComp;
_wonderflAPI.loadFollow();
}
private function atFollowComp():void {
_followersThumb = _multiLoaderClass.setLoad(_wonderflAPI.followersSrc,atFollowersComp);
}
private function atFollowersComp(errors:Array):void {
followers = spFromLoaders(_followersThumb,_wonderflAPI.followersTitle,new ColorTransform(0.3,0.3,0.3,1));
_followingThumb = _multiLoaderClass.setLoad(_wonderflAPI.followingSrc,atFollowingComp);
}
private function atFollowingComp(errors:Array):void {
following = spFromLoaders(_followingThumb,_wonderflAPI.followingTitle,new ColorTransform());
_frendsThumb = _multiLoaderClass.setLoad(_wonderflAPI.freindsSrc,atFrendsComp);
}
private function atFrendsComp(errors:Array):void {
frends = spFromLoaders(_frendsThumb,_wonderflAPI.freindsTitle,new ColorTransform());
atComp();
}
private function spFromLoaders(loaders:Array,titles:Array,colorTransform:ColorTransform):Array {
var array:Array = [];
if (!loaders) {
return array;
}
var n:int = loaders.length;
for (var i:int = 0; i < n; i++) {
if (loaders[i]) {
var r:int = 25;
var bitmapData:BitmapData = new BitmapData(r*2,r*2,true,0xFF0000);
var w:int = loaders[i].width;
var h:int = loaders[i].height;
bitmapData.draw(loaders[i].content,new Matrix(r*2/w,0,0,r*2/h),colorTransform,null,null,true);
var sp:Sprite = new Sprite();
sp.graphics.beginBitmapFill(bitmapData,new Matrix(),false,true)
sp.graphics.drawCircle(r,r,r-1);
sp.graphics.endFill();
sp.name = titles[i];
sp.buttonMode = true;
array.push({"image":sp});
}
}
return array;
}
}

/*
* WonderflAPIやスクレイピングをして、データを取得
* */
import com.adobe.serialization.json.JSON;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;

class WonderflAPI{
public var key:String = "68cdee400688f6c1d7abe138bf209a867278e573";//loaderInfo.parameters.open_api_key;
private const BASE_URL:String = "http://api.wonderfl.net";
private var userName:String;
public var atUserComp:Function = function():void{};
public var atFollowComp:Function = function():void{};
public var data:Object;
private var userCompCount:int;
public var followingTitle:Array;
public var followingSrc:Array;
public var followersTitle:Array;
public var followersSrc:Array;
public var freindsTitle:Array;
public var freindsSrc:Array;
public function WonderflAPI(userName:String):void{
if(key == ""){
//key = loaderInfo.parameters.open_api_key;
}
this.userName = userName;
data = {};
}
public function loadUserData():void{
userCompCount = 0;
var loader1:URLLoader = new URLLoader();
loader1.addEventListener(Event.COMPLETE, atUserComplete);
loader1.load(new URLRequest(BASE_URL + "/user/" + userName + "?api_key=" + key));
var loader2:URLLoader = new URLLoader();
loader2.addEventListener(Event.COMPLETE, atUserComplete);
loader2.load(new URLRequest(BASE_URL + "/user/" + userName + "/codes?api_key=" + key));
}
public function loadCodes(type:String):void{
var loader:URLLoader = new URLLoader();
if(type == "user"){
loader.load(new URLRequest(BASE_URL + "/user/" + userName + "?api_key=" + key));
}else if(type == "userCodes"){
loader.load(new URLRequest(BASE_URL + "/user/" + userName + "/codes?api_key=" + key));
}
//loader1.load(new URLRequest(BASE_URL + "/user/" + userName + "?api_key=" + KEY));
//loader2.load(new URLRequest(BASE_URL + "/user/" + userName + "/codes?api_key=" + KEY));
//loader2.load(new URLRequest(BASE_URL + "/code/" + "6c8e1242b3b579be206fe52167d3a15696f9a086" + "?api_key=" + KEY));
//loader2.load(new URLRequest(BASE_URL + "/code/" + "f4966c7c4356de0d287a06bc547efd76a84a1479" + "/forks?api_key=" + KEY));
}
private function atUserComplete(e:Event):void {
//trace(e.target.data)
var json:Object = JSON.decode(e.target.data);
if(json.user){
data["user"] = json.user;
}else if(json.codes){
data["userCodes"] = json.codes;
}
userCompCount++;
if(userCompCount == 2){
atUserComp();
}
}
////////////
public function loadFollow():void {
loadFollowing();
loadFollowers();
}
private function atFollowComplete():void {
if (followingTitle != null && followersTitle != null) {
freindsTitle = [];
freindsSrc = [];
var n:int = followingTitle.length;
for (var i:int = 0; i < n; i++) {
var m:int = followersTitle.length;
for (var j:int = 0; j < m; j++) {
if (followingTitle[n-i-1] == followersTitle[m-j-1]) {
followingSrc.splice(n-i-1, 1);
freindsSrc.push(followersSrc.splice(m – j – 1, 1).toString());

followingTitle.splice(n-i-1, 1);
freindsTitle.push(followersTitle.splice(m – j – 1, 1).toString());
}else {
//trace(followingTitle[n-i-1] , followersTitle[m-j-1])
}
}
}
atFollowComp();
}
}
//htmlをスクレイピング
public function loadFollowing():void {
var myURLLoader:URLLoader = new URLLoader();
myURLLoader.addEventListener (Event.COMPLETE, atFollowingComplete);
//YahooPipesの汎用feedPage
var jsonURL:String = "http://pipes.yahooapis.com/pipes/pipe.run?_id=68fa588146242e845cbac5f0ce3804a2&_render=json&url=";
//encodeURIComponentでエスケープして、feedProxyにくっつける。
jsonURL += encodeURIComponent("http://wonderfl.net/user/"+userName);
myURLLoader.load(new URLRequest(jsonURL));
}
private function atFollowingComplete(e:Event):void
{
followingTitle = [];
followingSrc = [];
//jsonとして受け取る
var json:Object = JSON.decode(e.target.data);
if (json.value.items[0] == undefined) {
atFollowComplete();
return;
}
var jsonString:String = json.value.items[0].content;
//一部imgタグが閉じてないので、置き換え
jsonString = jsonString.replace(/class="btn"><\/a>/g, "class=’btn’ \/><\/a>");
//一部のユーザーのページ(http://wonderfl.net/user/alumican_net)でパースがうまくいかないことがあるので。
try {
var bookXML:XML = new XML(jsonString);
var n:int = bookXML.div.div[1].div[1].div.div.length();
for (var i:int = 0; i < n; i++) {
if (bookXML.div.div[1].div[1].div.div[i].span.a[0]) {
followingSrc.push("http://api."+String(bookXML.div.div[1].div[1].div.div[i].span.a[0].img.@src).substr(7));
followingTitle.push(bookXML.div.div[1].div[1].div.div[i].span.a[0].img.@title);
}
}
}catch (error:*) {

}
atFollowComplete();
}
///
public function loadFollowers():void {
var myURLLoader:URLLoader = new URLLoader();
myURLLoader.addEventListener (Event.COMPLETE, atFollowersComplete);
//YahooPipesの汎用feedPage
var jsonURL:String = "http://pipes.yahooapis.com/pipes/pipe.run?_id=68fa588146242e845cbac5f0ce3804a2&_render=json&url=";
//encodeURIComponentでエスケープして、feedProxyにくっつける。
jsonURL += encodeURIComponent("http://wonderfl.net/user/" + userName + "/followers");
myURLLoader.load(new URLRequest(jsonURL));
}
private function atFollowersComplete(e:Event):void
{
followersTitle = [];
followersSrc = [];
//jsonとして受け取る
var json:Object = JSON.decode(e.target.data);
if (json.value.items[0] == undefined) {
atFollowComplete();
return;
}
var jsonString:String = json.value.items[0].content;
//一部imgタグが閉じてないので、置き換え
jsonString = jsonString.replace(/class="btn"><\/a>/g, "class=’btn’ \/><\/a>");
//XML型にする
var bookXML:XML = new XML(jsonString);
var n:int = bookXML.div.div[1].div[1].div[1].div.length();
for (var i:int = 0; i < n; i++) {
followersSrc[i] = "http://api."+String(bookXML.div.div[1].div[1].div[1].div[i].span.a[0].img.@src).substr(7);
followersTitle[i] = bookXML.div.div[1].div[1].div[1].div[i].span.a[0].img.@title;
}
atFollowComplete();
}
}

/*
* Fileローダー
* */
import flash.system.Security;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.display.Loader;
//import flash.display.LoaderInfo;
import flash.system.LoaderContext;

class MultiLoaderClass{

private var onComplete:Function = function(arg:Array=null):void{};
//private var onOpen:Function = function():void{};
private var loadNum:int;
private var loadCompNum:int;
private var error_array:Array = new Array();
private var URLs_array:Array = new Array();
public var _uniqueParam:String = "";
public var isCheckPolicyFile:Boolean;

public function set uniqueParam(uStr:String):void {
if (uStr) {
if (uStr.substr(0,2) == "?=") {
_uniqueParam = uStr;
}else {
_uniqueParam = "?=" + uStr;
}
}else {
_uniqueParam = "";
}
}
public function get uniqueParam():String {
return _uniqueParam;
}

public function MultiLoaderClass(_str:String = null,uStr:String = null){
if(_str){
Security.loadPolicyFile(_str);
}
uniqueParam = uStr;
}

public function setLoad(__item_array:Array = null, _onComp:Function = null):Array {
//trace(__item_array)
loadCompNum = loadNum = 0;
if(_onComp != null){
onComplete = _onComp;
}
if (__item_array.length == 0) {
loadNum ++;
onComplete([]);
}

URLs_array = __item_array.concat();
error_array = new Array();
//trace(__item_array.length)
//onOpen = _onOpen;
var _array:Array = new Array();
var _length:int = __item_array.length;
for (var i:int = 0; i < _length; i++) {
error_array[i] = false;
if (__item_array[i] == null) { continue };
var _extension:String = __item_array[i].substr(-4,4).toLowerCase();//拡張子を取り出す。
if (_extension == ".xml" || _extension == "html") {
//trace("**",__item_array[i]);
loadNum ++;
_array[i] = fnURLLoader(__item_array[i] + uniqueParam);
}else if(_extension == ".jpg" || _extension == ".gif" || _extension == ".png" || _extension == ".swf"){
loadNum ++;
_array[i] = img(__item_array[i] + uniqueParam);
}else if(_extension == ".bin"){
loadNum ++;
__item_array[i] = __item_array[i].substr(0, __item_array[i].length – 4);
_array[i] = binaryFromURL(__item_array[i] + uniqueParam);
}else{
//trace(__item_array[i])
loadNum ++;
_array[i] = img(__item_array[i] + uniqueParam);
//_array[i] = null;
}
}

return _array;
}
private function binaryFromURL(__url:String):URLLoader{
var _loader:URLLoader = new URLLoader();
_loader.dataFormat = URLLoaderDataFormat.BINARY;
_loader.addEventListener(Event.COMPLETE,completeHandler);
_loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
_loader.load(new URLRequest(__url));
return _loader;
}

private function fnURLLoader(__url:String):URLLoader{
var _loader:URLLoader = new URLLoader();
_loader.addEventListener(Event.COMPLETE,completeHandler);
_loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
//_loader.addEventListener(Event.OPEN,openHandler);
_loader.load(new URLRequest(__url));
//trace(_loader.loaderInfo);//.loaderURL
return _loader;
}

private function img(__url:String):Loader {
var _loader:Loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
//_loader.contentLoaderInfo.addEventListener(Event.OPEN,openHandler);
_loader.load(new URLRequest(__url),new LoaderContext(isCheckPolicyFile));
//_loader.name = __url;

return _loader;
}

private function completeHandler(event:Event = null):void {
loadCompNum ++;
if(loadCompNum == loadNum){
onComplete(error_array);
}
//var loaderInfo:LoaderInfo=event.currentTarget as LoaderInfo;
//var loader:Loader=loaderInfo.loader;
//addChild(loader);
}
private function openHandler (event:Event):void {
if(Math.random()>0.95){
trace ("読み込みを開始した");
//event.currentTarget.contentLoaderInfo.close();
var str:String = event.currentTarget.toString().substr(8);
if(str == "LoaderInfo]"){
//event.currentTarget.contentLoaderInfo.close();
//event.target.contentLoaderInfo.close();
//event.currentTarget.close();
//event.target.close();
}else if(str == "URLLoader]"){
event.currentTarget.close();
completeHandler();
}

//completeHandler();
//onOpen();
}
}

private function ioErrorHandler(event:IOErrorEvent):void {
//event.text = "Error #2035: URL が見つかりません。 URL: file:///~~~~~";
//event.text = "Error #2036: 読み込みが未完了です。 URL: http://~~~~~";
//から、URLのみを取り出す。
//trace(String(event.text).substr(String(event.text).indexOf(" URL: ")+6),"*****");
for (var i:int = 0; i < URLs_array.length; i++) {
var _str:String = String(event.text).substr(String(event.text).indexOf(" URL: ")+6).substr(-URLs_array[i].length);
if(URLs_array[i] == _str){
error_array[i] = true;
//trace("これだ",i,_str)
}
}

//URLs_array
completeHandler();
}
}

[/sourcecode]