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

forked from: massmedian challenge

Get Adobe Flash player
by k3lab 10 Jul 2009
/**
 * Copyright k3lab ( http://wonderfl.net/user/k3lab )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6K2W
 */

// forked from checkmate's massmedian challenge
package {
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	import flash.net.*;
         import flash.system.LoaderContext;
	[SWF(width = "465", height = "465", frameRate = "60")]
	public class Begineer extends Sprite{
		
		
		//-------------------------------//
		// Use properties as follows.
		//-------------------------------//
		private var _sliceList:Array;
		
                  private var canvas:BitmapData
                  private var w:int = 525
                  private var h:int = 70
                  private var app:Array=[]
                  private var rand:int;
                  private var n:int
                  private var w_count:int=60
                  private var h_count:int=10
		private var count:int=200
		
		//-------------------------------//
		// Change functions as follows.
		//-------------------------------//
		public function updateEnterFrame( e:Event ):void{
                        if(canvas==null){
                            canvas = new BitmapData(w, h, true);
                            while (n < count) {
                                app[n] = new Point(Math.random() * w, Math.random() * h);
                                ++n;
                            }
                        }
                        for ( var i:int = 0; i <w_count; i++ ) { 
                            for ( var j:int = 0; j < h_count; j++ ) {  
                                var sq:DisplayObject = _sliceList[(10* i + j) * 1]
                                var px:Number = canvas.getPixel(i * Math.random()*10, j * Math.random()*2);
                                px = px / 70000
                                if (sq != null) {
                                    sq.y = px + 6;
                                   
                                    sq.rotationZ = px + 2;
                                    sq.z=px+2
                                }	
                            }
                        }
                        var es:int
                        while (es < count) {
                            app[es].x +=5;
                            app[es].y +=2.5;
                            ++es;
                        }
                        canvas.perlinNoise(w, h, 1, 1, false, false, 1, true, app);
		} 
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		//-------------------------------//
		// Do not change following codes.
		//-------------------------------//
		public function Begineer(){
            var ctxt  :LoaderContext = new LoaderContext(true);
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onLoadComplete );
			loader.load( new URLRequest("http://swf.wonderfl.net/static/assets/massmedian.png"), ctxt );
        }
		
		public function onLoadComplete(e:Event):void {
			var loader:Loader = LoaderInfo( e.target ).loader;
			loader.contentLoaderInfo.removeEventListener( Event.COMPLETE, onLoadComplete );
			
			var bitmapdata:BitmapData = new BitmapData( loader.width, loader.height, true, 0xFF0000 );
			bitmapdata.draw( loader );
			
			_sliceList = sliceBanner( bitmapdata, bitmapdata.width );
			
			addEventListener( Event.ENTER_FRAME, updateEnterFrame );
		}
		
		
		private function sliceBanner( banner:BitmapData, length:int = 100 ):Array{
			var sliceList:Array = [];
			var w:int = Math.floor( banner.width/length );
			var h:int = Math.floor( banner.height );
			
			var t:int = Math.ceil( banner.width - w*length );
			var mat:Matrix = new Matrix();
				
			for( var i:int = 0; i<length; i++ ) {
				var bmpd :BitmapData = new BitmapData( w, h, true, 0xFFFF00 );
				mat.tx = -w*i;
				bmpd.draw( banner, mat );
				var part:DisplayObject = addChild( new Bitmap( bmpd ) );
				part.x = w*i;
				sliceList.push( part );
			}
			return sliceList;
		}
		
	}
}