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

What you gonna do?

Copyright shohei909 ( http://wonderfl.net/user/shohei909 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/luwz
Get Adobe Flash player
by uwi 15 Aug 2010
    Embed
/**
 * Copyright uwi ( http://wonderfl.net/user/uwi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bzJZ
 */

/**
 * Copyright shohei909 ( http://wonderfl.net/user/shohei909 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/luwz
 */
package {
    import flash.geom.Matrix;
    import flash.system.LoaderContext;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.display.*;
    import flash.text.*;
    
    public class MediaRSSReader extends Sprite {
        private var _feed:String = "http://api.flickr.com/services/feeds/photos_public.gne?tags=flowers,field&tagmode=all&format=rss_200";
        private var media:Namespace = new Namespace("http://search.yahoo.com/mrss/");
        
        private var _tf : TextField;
        private var _ls : Array;
        private var _lct : uint; // ロード済みの画像のカウンター
        private const N : uint = 3; // ロードする画像の個数
        private const M : uint = 10; // 遊助の数
        private var _bmdb : BitmapData;
        private var _bees : Array;
        
        public function MediaRSSReader() {
            Wonderfl.capture_delay(7);
            
            _tf = new TextField();
            _tf.width = 200;
            addChild(_tf);
            _tf.appendText("Loading...\n");
            
            _ls = [];
            _lct = 0;
            _bees = [];
            
            var ldr:URLLoader = new URLLoader;
            var mx : Number = 0;
            ldr.addEventListener(Event.COMPLETE, function (e:Event):void {
                ldr.removeEventListener(Event.COMPLETE, arguments.callee);
                var xml : XML = XML(ldr.data);
                var len : uint = xml..media::content.@url.length();
                for(var i : uint = 0;i < N;i++){
                    var ind : uint = Math.random() * len;
                    var url : String = xml..media::content.@url[ind].toXMLString();
                    var h : Number = xml..media::content.@height[ind].toXMLString();
                    var w : Number = xml..media::content.@width[ind].toXMLString();
                    _tf.appendText(url + "\n");
                    _tf.appendText(h + "\n");
                    _tf.appendText(w + "\n");
                
                    var l : Loader = new Loader();
                    _ls.push(l);
                    l.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event) : void
                    {
                        l.contentLoaderInfo.removeEventListener(Event.COMPLETE, arguments.callee);
                        _lct++;
                        if(_lct == N){
                            addEventListener(Event.ENTER_FRAME, onEnterFrame);
                        }
                    });

                    l.load(new URLRequest(url));
                    l.x = mx;
                    l.y = 0;
                    l.scaleY = stage.stageHeight / h;
                    l.scaleX = l.scaleY;
                    mx += w * l.scaleX;
                    addChild(l);
                }
                
                var boon : Loader = new Loader();
                boon.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event) : void
                {
                    boon.contentLoaderInfo.removeEventListener(Event.COMPLETE, arguments.callee);  
                    _bmdb = new BitmapData(boon.width, boon.height, true, 0x00000000);
                    _bmdb.draw(boon.content);
                    for(var x : uint = 0;x < boon.width;x++){
                        for(var y : uint = 0;y < boon.height;y++){
                            if((x - boon.width / 2) * (x - boon.width / 2) + (y - boon.height / 2) * (y - boon.height / 2) >= 250 * 250){
                                _bmdb.setPixel32(x, y, 0);
                            }
                        }
                    }
                    
                    _bees = [];
                    for(var i : uint = 0;i < M;i++){
                        var bmp : Bitmap = new Bitmap(_bmdb);
                        bmp.x = -bmp.width / 2;
                        bmp.y = -bmp.height / 2;
                        
                        var cont : Sprite = new Sprite();
                        cont.addChild(bmp);
                        cont.x = -1000000;
                        addChild(cont);
                         
                        var info : Object = {
                            x : Math.random() * stage.stageWidth * 3 / 4 + stage.stageWidth / 8,
                            y : Math.random() * stage.stageHeight * 3 / 4 + stage.stageHeight / 8,
                            ax : Math.random() * 0.08,
                            ay : Math.random() * 0.08,
                            asc : Math.random() * 0.05,
                            asz : Math.random() * 0.05,
                            wx : Math.random() * 100,
                            wy : Math.random() * 100,
                            omega : Math.random() * 10 - 5,
                            sy : 0.4,
                            size : 100,
                            sx : 0,
                            cont : cont,
                            bmp : bmp
                        };
                        
                        _bees.push(info);
                    } 
                });

                boon.load(new URLRequest("http://assets.wonderfl.net/images/related_images/b/b2/b272/b272d461b7cc7a64e7f7dd597d89bdeb56921b2e"), new LoaderContext(true));
            });
            ldr.load(new URLRequest(_feed));
        }
        
        private var _t : Number = -Math.random() * 99999999;
        
        // ぐるぐる
        private function onEnterFrame(e : Event) : void
        {
            for each(var l : Loader in _ls){
                l.x-=2;
            }
            if(_ls[1].x <= 0){
                var ro : Loader = _ls.shift();
                var last : Loader = _ls[_ls.length - 1];
                ro.x = last.x + last.width;
                _ls.push(ro);
            } 
            
            for each(var b : Object in _bees){
                b.cont.x = b.x + b.wx * Math.cos(_t * b.ax);
                b.cont.y = b.y + b.wy * Math.cos(_t * b.ay);
                b.bmp.rotation += b.omega;
                b.cont.scaleX = (b.size + 50 * Math.cos(_t * b.asz)) / _bmdb.width;
                b.cont.scaleY = b.cont.scaleX * (b.sy + 0.1 * Math.cos(_t * b.asc));
                b.sx = b.cont.scaleX;
            }
            
            // Z-sort
            _bees.sortOn("sx", Array.NUMERIC);
            for each(b in _bees){
                addChild(b.cont);
            }

            
            _t++;
        }

    }
}