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 2010-1-1

Get Adobe Flash player
by _ryotaros 02 Jan 2010
    Embed
/**
 * Copyright _ryotaros ( http://wonderfl.net/user/_ryotaros )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/qjys
 */

package {
      import flash.display.*;
      import flash.events.*;
      import flash.utils.*;
      import flash.filters.*;
      import flash.geom.*;
      import org.libspark.betweenas3.*;
      import org.libspark.betweenas3.easing.*;
      import org.libspark.betweenas3.tweens.*;
      import org.papervision3d.core.effects.*;
      import org.papervision3d.core.effects.utils.*;
      import org.papervision3d.view.layer.*;
      import org.papervision3d.materials.*;
      import org.papervision3d.materials.utils.*;
      import org.papervision3d.objects.*;
      import org.papervision3d.objects.primitives.*;
      import org.papervision3d.view.*;
    
    [SWF(width = 465,height = 465, backgroundColor = 0)]
    public class FlashTest extends BasicView {
    		
    		public const PIXEL_NUM:int = 22;
    		public const PIXEL_MARGIN:int = 20;
    		public const PIXEL_SIZE:int = 100;
    		public const MAX_RADIUS:int = 3000;
    		public var plane_Array:Array = [];
    		public var dummy_Plane:Array = [];
    		public var dummyObj:Array = [];
    		public var index:int = 0;
    		
    		static private const IMAGE_LIST:Array = [
            [
                [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0], 
                [0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0], 
                [0,0,0,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0], 
                [0,0,0,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0], 
                [0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0], 
                [0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0], 
                [0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0], 
                [0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0], 
                [0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0], 
                [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0], 
                [0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0], 
                [0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0], 
                [0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0], 
                [0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0], 
                [0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
            ],
            [
                [0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0], 
                [0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0], 
                [0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0], 
                [0,0,0,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0], 
                [0,1,1,1,1,1,1,1,0,0,1,1,0,0,1,1,1,1,1,1,1,0], 
                [0,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0], 
                [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], 
                [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], 
                [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], 
                [0,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0], 
                [0,1,1,1,1,1,1,1,0,0,1,1,0,0,1,1,1,1,1,1,1,0], 
                [0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,1,1,1,0,0,0], 
                [0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0], 
                [0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0]
            ]
        ];

    		public function FlashTest():void {
    			
    			//camera.z = -MAX_RADIUS;
    			
    		    var timer:Timer = new Timer(7000);
            timer.addEventListener(TimerEvent.TIMER, loop);
            timer.start()
    			
    			main();
    			
    			camera.z -= 2000;
    			setTimeout(loop, 100);
    			
    			startRendering();
    			
    			addEventListener(Event.ENTER_FRAME, enterframe);
    		}
    		
        public function main():void {
        	
        		var bfx:BitmapEffectLayer = new BitmapEffectLayer(viewport);
        		bfx.addEffect(new BitmapLayerEffect(new BlurFilter(16, 16, 5)));
        		bfx.drawCommand = new BitmapDrawCommand(null, new ColorTransform(1, 1, 0.15), BlendMode.ADD );
        		bfx.clippingPoint = new Point (0, 0);
        		viewport.containerSprite.addLayer(bfx);
            
            var material:ColorMaterial = new ColorMaterial(0XFFFFFF,1,false);
            for (var i:int = 0;i < PIXEL_NUM;i++){
            		plane_Array[i] =[];
            		for (var j:int = 0;j < PIXEL_NUM;j++){
            			plane_Array[i][j] = new Plane(material, PIXEL_SIZE, PIXEL_SIZE);
            			plane_Array[i][j].x = ( +i - PIXEL_NUM / 2) * (PIXEL_SIZE + PIXEL_MARGIN);
            			plane_Array[i][j].y = ( -j + PIXEL_NUM / 2) * (PIXEL_SIZE + PIXEL_MARGIN);    
            			bfx.addDisplayObject3D(plane_Array[i][j]);        			
            			scene.addChild(plane_Array[i][j]);			
            		}
            }
			
		   dummy_Plane =[];	
           for (var k:int = 0;k < IMAGE_LIST.length; k++){
           	   dummyObj[k] = new DisplayObject3D();
           	   dummyObj[k].x = MAX_RADIUS *(Math.random() - 0.5 );
           	   dummyObj[k].y = MAX_RADIUS *(Math.random() - 0.5 );
          	   dummyObj[k].z = MAX_RADIUS *(Math.random() - 0.5 );  
          	   scene.addChild(dummyObj[k]);
          	   
          	   dummy_Plane[k] = [];
          	   
          	   for (i = 0;i < PIXEL_NUM;i++){
          	   		dummy_Plane[k][i] = [];
          	   		for (j = 0; j < PIXEL_NUM;j++){
          	   			dummy_Plane[k][i][j] = new DisplayObject3D();
          	   			//dummy_Plane[k][i][j] = new Plane(new WireframeMaterial(), PIXEL_SIZE, PIXEL_SIZE);
          	   			dummy_Plane[k][i][j].x = ( +i - PIXEL_NUM / 2) * (PIXEL_SIZE + PIXEL_MARGIN);
          	   			dummy_Plane[k][i][j].y = ( -j + PIXEL_NUM / 2) * (PIXEL_SIZE + PIXEL_MARGIN);
          	   			dummyObj[k].addChild(dummy_Plane[k][i][j]);
          	   		}
          	   }
          	   
           }
           
        }
        
        public function enterframe(e:Event):void{
        		var rateX:Number = mouseX / stage.stageWidth;
        		camera.x = -5000 * (rateX - 0.5);
        		
        		var rateY:Number = mouseY / stage.stageHeight;
        		camera.y = 5000 * (rateY - 0.5);
        		
        }
        
        public function loop(e:TimerEvent = null):void {
        		index++;
        		if (index == IMAGE_LIST.length) {index = 0;}
        		
        		for (var i:int = 0;i < PIXEL_NUM; i++ ){
        			for (var j:int = 0;j < PIXEL_NUM; j++){
        			    var p:DisplayObject3D = plane_Array[i][j];
        			    var d:DisplayObject3D = dummy_Plane[index][j][i];
        			    var s:Object = IMAGE_LIST[index][i][j];
        			    
        			    BetweenAS3.delay(
                        BetweenAS3.bezier(p,
                            {
                                x : d.sceneX,
                                y : d.sceneY,
                                z : d.sceneZ,
                                scale : s
                            },
                            null, 
                            {
                                x : MAX_RADIUS * (Math.random() - 0.5),
                                y : MAX_RADIUS * (Math.random() - 0.5),
                                z : MAX_RADIUS * (Math.random() - 0.5)
                            }, 
                            5 + Math.random(), 
                            Quart.easeInOut),
                        Math.random() * 1
                    ).play();
        			}
        		}
        }
    }
}