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: 3Dぐりぐり (3)

Get Adobe Flash player
by maxpop 06 Aug 2009
    Embed
/**
 * Copyright maxpop ( http://wonderfl.net/user/maxpop )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/r8J2
 */

// forked from nacookan's  3Dぐりぐり (3)
package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.geom.Point;

    [SWF(backgroundColor="0x000000", frameRate="60")]

    public class Guriguri3DCube extends Sprite {
        
        private var antal:Number = 20;
        public function Guriguri3DCube() {
            var canvas:Sprite = new Sprite();
            for(var i:Number = 0; i < 50; i++){
                var cube:Sprite = generateCube();
                cube.x = rnd(350);
                cube.y = rnd(350);
                cube.z = 100 - (i * (100 / 200));
                canvas.addChild(cube);
            }
            
            addChild(canvas);
            addEventListener(Event.ENTER_FRAME, function(e:Event):void{
                transform.perspectiveProjection.projectionCenter = new Point(mouseX, mouseY);
            });
        }
        
        private function generateCube():Sprite{
            var cube:Sprite = new Sprite();
            var color:Number = 0x555555;
            
            var w1:Sprite = generateWall(color);
            w1.x = 0;
            w1.y = 0;
            w1.z = 0;
            w1.rotationX = 90;
            cube.addChild(w1);
            
            var w2:Sprite = generateWall(color);
            w2.x = 0;
            w2.y = 0;
            w2.z = antal;
            cube.addChild(w2);
            
            var w3:Sprite = generateWall(color);
            w3.x = 0;
            w3.y = 0;
            w3.z = 0;
            w3.rotationY = -90;
            cube.addChild(w3);
            
            var w4:Sprite = generateWall(color);
            w4.x = antal;
            w4.y = 0;
            w4.z = antal;
            w4.rotationY = 90;
            cube.addChild(w4);
            
            var w5:Sprite = generateWall(color);
            w5.x = 0;
            w5.y = antal;
            w5.z = antal;
            w5.rotationX = -90;
            cube.addChild(w5);
            
            var w6:Sprite = generateWall(color);
            w6.x = 0;
            w6.y = 0;
            w6.z = 0;
            cube.addChild(w6);
             
            return cube;
        }
        
        private function generateWall(color:Number):Sprite{
            var wall:Sprite = new Sprite();
            wall.graphics.lineStyle(1, 0x777777, 1);
            wall.graphics.beginFill(color, 1);
            wall.graphics.drawRect(0, 0, antal, antal);
            wall.graphics.endFill();
            return wall;
        }
         
        private function rnd(max:Number):Number{
            return Math.floor(Math.random() * max);
        }           
    }
}