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-4-28

Get Adobe Flash player
by yonatan 27 Apr 2009
/**
 * Copyright yonatan ( http://wonderfl.net/user/yonatan )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/y61m
 */

package {
    import flash.events.*;
    import org.papervision3d.materials.*;
    import org.papervision3d.materials.utils.*;
    import org.papervision3d.objects.*;
    import org.papervision3d.objects.primitives.*
    import org.papervision3d.view.*;
    import org.papervision3d.core.math.Number3D;
    import org.papervision3d.core.geom.renderables.Vertex3D;
    
    import caurina.transitions.Tweener;

    public class Main extends BasicView {
        private var cube      :Cube;
        
        public function Main() {
            var materials :MaterialsList = new MaterialsList( { all : new WireframeMaterial( 0xD7261C ) } );
            cube = new Cube( materials, 500, 500, 500, 10, 10, 10 );
            scene.addChild( cube );
            addEventListener( Event.ENTER_FRAME, onEnterFrame );
            stage.addEventListener( MouseEvent.CLICK, onClick );
        }
        
        public function onClick(e:MouseEvent): void {
            var vertices:Array = cube.geometry.vertices;
            var x:Number, y:Number, z:Number, len:Number;
            
            for each( var v:Vertex3D in vertices ) {
                x = v.x; y = v.y; z = v.z;
                len = Math.sqrt(x*x+y*y+z*z) / 400;
                x /= len;
                y /= len;
                z /= len;
                Tweener.addTween( v, {x: x, y: y, z: z, time: 4, transition: "linear"} );
            }
        }
        
        public function onEnterFrame(e:Event): void {
            cube.rotationY++;
            renderer.renderScene( scene, camera, viewport );
        }
    }
}