ふわふわ...
ふわふわ...
ふわふわ...
/**
* Copyright Dorara ( http://wonderfl.net/user/Dorara )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/5POo
*/
//ふわふわ...
// ふわふわ...
package {
import com.actionsnippet.qbox.*;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
[SWF(width="465", height="465",backgroundColor=0xffffff,frameRate=60)]
public class MediaRSSQBox extends MovieClip
{
public var mrss:MediaRSSLoader;
public var sim:QuickBox2D;
public var textF:TextField;
public function MediaRSSQBox()
{
mrss = new MediaRSSLoader();
textF = new TextField();
this.addChild(textF);
textF.text = "loading...";
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function onEnterFrame(e:Event):void{
if(mrss.flag){
textF.text = "complete: " + mrss.compN.toString() + "/" + mrss.bmps.length.toString();
if(mrss.compN == (int)(mrss.bmps.length)){
mrss.flag = false;
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
startQB2D();
}
}
}
public function startQB2D():void{
sim = new QuickBox2D(this,{gravityX:0,gravityY:0});
sim.setDefault({lineColor:0xffffff, fillColor:0xffffff});
sim.createStageWalls();
for(var i:int = 0; i<14; i++){
var sp:Sprite = new Sprite();
sp.addChild(mrss.bmps[i]);
sp.x=-(mrss.bmps[i].width/2); sp.y=-(mrss.bmps[i].height/2);
var obj:QuickObject = sim.addBox({x:14*Math.random(),y:14*Math.random(),width:2.5,height:2.5});
obj.userData.addChild(sp);
}
sim.start();
sim.mouseDrag();
}
}
}
import flash.net.URLRequest;
import flash.events.Event;
import flash.net.URLLoader;
import flash.system.Security;
import flash.display.*;
class MediaRSSLoader extends Sprite {
private var _feed:String = "http://api.flickr.com/services/feeds/photos_public.gne?tags=kamakura&format=rss_200";
private var media:Namespace = new Namespace("http://search.yahoo.com/mrss/");
public var bmps:Array;
public var flag:Boolean;
public var compN:int;
public function MediaRSSLoader() {
bmps = new Array();
compN = 0;
flag = false;
Security.loadPolicyFile("http://farm5.static.flickr.com/crossdomain.xml");
var ldr:URLLoader = new URLLoader;
ldr.addEventListener(Event.COMPLETE, function _load(e:Event):void {
ldr.removeEventListener(Event.COMPLETE, _load);
onImageLoaded(XML(ldr.data)..media::thumbnail.@url.toXMLString().split('\n'));
});
ldr.load(new URLRequest(_feed));
}
private function onImageLoaded($images:Array):void {
var container:Sprite = new Sprite;
var ldr:Loader;
for (var i:int = 0; i < $images.length; ++i) {
ldr = new Loader;
ldr.load(new URLRequest($images[i]));
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, function _loadimage(e:Event):void{
compN++;
});
ldr.x = 0;
ldr.y = 0;
bmps.push(ldr);
}
flag = true;
}
}