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

CUEB demo

Flash
Caurina
Papervision3d
Get Adobe Flash player
by fabu 12 Aug 2010
    Embed
package {
    // Flash
    import flash.text.TextField;
    import flash.events.*;
    import flash.filters.*;
    import flash.utils.*;
    import flash.geom.*;
    import flash.display.*;
    import flash.geom.*;

    // Caurina
    import caurina.transitions.*;

    // Papervision3d
    import org.papervision3d.objects.*;
     import org.papervision3d.events.*;
    import org.papervision3d.materials.shadematerials.*;
    import org.papervision3d.core.effects.*;
    import org.papervision3d.core.effects.utils.*;
    import org.papervision3d.objects.*;
    import org.papervision3d.view.layer.*;
    import org.papervision3d.objects.primitives.*;
    import org.papervision3d.materials.utils.MaterialsList;
    import org.papervision3d.core.effects.view.ReflectionView;
    import org.papervision3d.lights.*;
    import org.papervision3d.core.math.*;

    [SWF(width = "465", height = "465", backgroundColor="#666666", fps = "30")]
    public class Main extends ReflectionView {
       
        //  Carousel
        // --------------------------------------------------------------
        private const radius:Number = 2000;
        private const number_of_cubes:int = 12;
        private var carousel:DisplayObject3D = new DisplayObject3D();   
        private var currentQuat:Quaternion = new Quaternion();
        private var targetQuat:Quaternion = new Quaternion();
        private var slerp:Number = 0;

        public function Main() {
            viewport.interactive = true;
            surfaceHeight = -1000;
            camera.z = 3500;
            camera.y = 800;

            // Cubes
            // --------------------------------------------------------------
            for(var i:int = 0; i < number_of_cubes; i++) {
                // Create
                var flatShadeMaterial:FlatShadeMaterial = new FlatShadeMaterial(new PointLight3D(), 0x2288cc, 0x004466);
                flatShadeMaterial.interactive = true;
                var cube:Cube = new Cube( new MaterialsList( {
                    all : flatShadeMaterial 
                }));

                // Position
                cube.rotationY = 360 / number_of_cubes * i;
                cube.moveForward(radius);   

                // Listeners
                cube.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, objectOverHandler);
                cube.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, objectOutHandler);
                cube.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, objectClickHandler);
 
                cube.addEventListener(MouseEvent.CLICK, showPlayer);            

                // Add
                carousel.addChild(cube);
            }
    
            scene.addChild(carousel);   
        
            addEventListener(Event.ENTER_FRAME, enterFrameHandler);
            
            viewport.filters = [new GlowFilter(0xcccccc, 0.8, 20, 20, 4, 3)];
            viewportReflection.filters = [new BlurFilter(2, 2, 2)];
            viewportReflection.filters = [new GlowFilter(0xcccccc, 1, 20, 20, 4, 3)];
            viewportReflection.alpha = .2;
            
            var bfx:BitmapEffectLayer = new BitmapEffectLayer(viewport);
            viewport.containerSprite.addLayer(bfx);
            
            bfx.addEffect( new BitmapLayerEffect( new BlurFilter(10,10,4)));
            //bfx.addEffect( new BitmapLayerEffect( new BlurFilter(25, 25, 4)));
            //bfx.addEffect( new BitmapColorEffect(.95, 1.0, .98, 0.98));
            
            var ct:ColorTransform = new ColorTransform(0, 0, 1, .08);
                        
            var drawCommand:BitmapDrawCommand = new BitmapDrawCommand(null, ct, BlendMode.ADD);
            bfx.drawCommand = drawCommand;
            bfx.drawLayer.filters = [ new GlowFilter(0xFFFFFF,.5, 0, 50, 10)];
            
            bfx.drawLayer.blendMode = BlendMode.MULTIPLY;
            bfx.clippingPoint = new Point(9, -20);
            bfx.addDisplayObject3D(carousel);
            
            addEventListener(Event.ENTER_FRAME, swing);
        }
 
        private function swing():void 
        {
            camera.y = 300 + 800 * Math.sin(getTimer() / 1000);
            singleRender();
        }

        private function showPlayer(event:MouseEvent):void
        {
            Tweener.addTween(viewport, { alpha:0.75, time:1});
            Tweener.addTween(camera, { z:(camera.z + 200), time:2, transition:"easeOutBounce"});   
        }

        private function objectOverHandler(event:InteractiveScene3DEvent):void 
        {
            viewport.buttonMode = true;
        }   

        private function objectOutHandler(event:InteractiveScene3DEvent):void
        {
            viewport.buttonMode = false; 
        }   

        private function objectClickHandler(event:InteractiveScene3DEvent):void
        {
            /*var msg:TextField = new TextField();
            msg.text = "Click !";
            addChild(msg);*/
            var radians:Number = (carousel.rotationY - event.displayObject3D.rotationY) * Quaternion.DEGTORAD;   
            slerp = 0;
            currentQuat = Quaternion.createFromMatrix(carousel.transform);
            targetQuat = Quaternion.createFromAxisAngle(0, 1, 0, radians);
        }  

        private function enterFrameHandler(event:Event):void 
        {
            slerp += (1 - slerp) * .05;
            var quat:Quaternion = Quaternion.slerp(currentQuat, targetQuat, slerp);   
            carousel.transform = quat.matrix;   
            singleRender(); 
        }
    }
}