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

flash on 2009-10-5

Get Adobe Flash player
by yd_niku 05 Oct 2009
    Embed
/**
 * Copyright yd_niku ( http://wonderfl.net/user/yd_niku )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mFFr
 */

package {
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.system.*;
    import flash.net.*;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            var loader :Loader = new Loader();
            loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onLoadImage );
            loader.load( new URLRequest("http://assets.wonderfl.net/images/related_images/0/0a/0aa3/0aa3a483675d47ee7967ffc1e9422cf19be47c79"), new LoaderContext(true) );
        }
        public function onLoadImage (e:Event ):void {
            var content:Loader = e.target.loader as Loader;
            var bm:BitmapData = new BitmapData(content.width, content.height);
            bm.draw( content );
            createBlocks( bm );
            
            addEventListener( Event.ENTER_FRAME, loop );
        }
        
        public function createBlocks( content:BitmapData ):void {
            var w:int = 10;
            var h:int = 10;
            
            const col:int = content.width/ w;
            const row:int = content.height/ h;
            
            for( var i:int = 0; i<col; ++i ) {
                for( var j:int = 0; j<row; ++j ) {
                    var bmd:BitmapData = new BitmapData( w, h, false, 0 );
                    var mat:Matrix = new Matrix();
                    mat.translate( -i * w, -j * h );
                    bmd.draw( content, mat );
                    var block :Sprite = addChild( new Sprite ) as Sprite ;
                    var bm:Bitmap = block.addChild( new Bitmap( bmd ) ) as Bitmap;
                    bm.x = -5;
                    bm.y = -5;
                    
                    block.x = i * w;
                    block.y = j * h;
                    _blocks.push( block);
                }
            }
        }
        private var _blocks:Array = [];
        
        private function loop(e:Event):void {
            for each( var i :DisplayObject in _blocks ) {
                i.rotationX += 3;
                //i.rotationY += 3;
            }
        }
    }
}