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

Alternativa3D demo

Alternativa3D demo via
http://clockmaker.jp/blog/2008/10/alternativa3d_helloworld/
Get Adobe Flash player
by mash 19 Oct 2010
// Alternativa3D demo via
// http://clockmaker.jp/blog/2008/10/alternativa3d_helloworld/
package
{
    import alternativ5.engine3d.controllers.*;
    import alternativ5.engine3d.core.*;
    import alternativ5.engine3d.display.*;
    import alternativ5.engine3d.materials.*;
    import alternativ5.engine3d.primitives.*;
    import alternativ5.types.*;
    import alternativ5.utils.*;
    
    import flash.net.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;

    [SWF(width="720", height="480", frameRate="60")]

    public class Main extends Sprite
    {
        private var scene:Scene3D;
        private var view:View;
        private var camera:Camera3D;
        private var cameraController:CameraController;
        private var wrap:Object3D;
        
        public function Main()
        {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            
            // Creating scene
            scene = new Scene3D();
            scene.root = new Object3D();
            
            wrap = scene.root.addChild(new Object3D());
            //wrap.y = 500;
            
            // create box
            var box:Box = Box(wrap.addChild(new Box()));
            box.cloneMaterialToAllSurfaces(new DevMaterial());
            box.x = 500 * Math.sin(0 * Math.PI / 180);
            box.z = 500 * Math.cos(0 * Math.PI / 180);
            
            var cone:Cone = Cone(wrap.addChild(new Cone()));
            cone.cloneMaterialToAllSurfaces(new DevMaterial());
            cone.x = 500 * Math.sin(90 * Math.PI / 180);
            cone.z = 500 * Math.cos(90 * Math.PI / 180);
            cone.rotationX = -90 * Math.PI / 180;
            
            //var sphere:Sphere = Sphere(wrap.addChild(new Sphere(100, 6, 6)));
            var sphere:GeoSphere = GeoSphere(wrap.addChild(new GeoSphere(100, 1)));
            sphere.cloneMaterialToAllSurfaces(new DevMaterial());
            sphere.x = 500 * Math.sin(180 * Math.PI / 180);
            sphere.z = 500 * Math.cos(180 * Math.PI / 180);
            
            var plane:Plane = Plane(wrap.addChild(new Plane()));
            //var geoPlane:GeoPlane = GeoPlane(wrap.addChild(new GeoPlane()));
            plane.cloneMaterialToAllSurfaces(new DevMaterial());
            plane.x = 500 * Math.sin(270 * Math.PI / 180);
            plane.z = 500 * Math.cos(270 * Math.PI / 180);
            
            
            // Adding camera and view
            camera = new Camera3D();
            camera.x = 0;
            camera.y = 0;
            camera.z = 1000;
            scene.root.addChild(camera);
            
            view = new View();
            addChild(view);
            view.camera = camera;

            // Connecting camera controller
            cameraController = new CameraController(stage);
            cameraController.camera = camera;
            cameraController.setDefaultBindings();
            cameraController.checkCollisions = false;
            cameraController.collisionRadius = 0;
            cameraController.lookAt(new Point3D());
            cameraController.controlsEnabled = false;
            
            // FPS display launch
            FPS.init(stage);
            createLogo();
            
            stage.addEventListener(Event.RESIZE, onResize);
            stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
            onResize(null);
        }
        
        private function onResize(e:Event):void
        {
            view.width = stage.stageWidth;
            view.height = stage.stageHeight;
            
            // BackGround Color
            var bgMatrix:Matrix = new Matrix();
            bgMatrix.rotate(90 * Math.PI / 180);
            graphics.clear()
            graphics.beginGradientFill("linear", [0xFFFFFF, 0x001122], [100, 100], [0, 255], bgMatrix);
            graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
        }
        
        private function onEnterFrame(e:Event):void
        {
            // Scene calculating
            scene.calculate();
            
            wrap.rotationY -= .015
        }
        
        private function createLogo():void
        {
            var sp:Sprite = Sprite(addChild(new Sprite()));
            //sp.addChild(new Logo())
            
            sp.buttonMode = true;
            sp.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void
            {
                navigateToURL( new URLRequest("http://alternativaplatform.com/en/"), "_blank");
            })
        }
    }
}