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

3d object using alternativa 7 ...

this code show you how to use alternativa 7 to create 3d object , set  camera  position on the stage ...and how to rotation the object using the mouse.... Thanks to the team that make the site supports alternativa 7 ...
Get Adobe Flash player
by yusufsaad 23 Oct 2012
/**
 * Copyright yusufsaad ( http://wonderfl.net/user/yusufsaad )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/dImr
 */

package {
    import flash.media.Camera;
    import flash.display.MovieClip;
    import alternativ7.engine3d.containers.ConflictContainer;
    import alternativ7.engine3d.containers.BSPContainer;
    import alternativ7.engine3d.core.Camera3D;
    import alternativ7.engine3d.primitives.Plane;
    import alternativ7.engine3d.primitives.Box;
    import alternativ7.engine3d.core.View;
    import flash.geom.ColorTransform;
    import alternativ7.engine3d.materials.Material;
    import alternativ7.engine3d.materials.FillMaterial;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.*;
    public class FlashTest extends MovieClip{
        private var container:BSPContainer = new BSPContainer();
        private var camera:Camera3D;
        private var plane:Plane;
        private var cube:Box;
        private var isDragging:Boolean = false;
        private var lastX:int;
        private var lastY:int;
        public function FlashTest() {
            // write as3 code here..
            camera = new Camera3D();
            camera.view = new View(600,600);
            camera.rotationX = 45 * Math.PI / 180;
            camera.y = 500;
            camera.z = -500;

            addChild(camera.view);
            addChild(camera.diagram);

            container.addChild(camera);
            //plane;
            plane = new Plane(600,600,10,10);
            plane.setMaterialToAllFaces(new FillMaterial(0xcccccc,0.7,1));
            container.addChild(plane);
            // object ;
            cube = new Box(50,50,150,2,2,4);
            cube.setMaterialToAllFaces(new FillMaterial(0x66cc33,10,0,0xff0000));
      
            container.addChild(cube);
            stage.addEventListener(Event.ENTER_FRAME,EnterFrame);
            stage.addEventListener(MouseEvent.MOUSE_DOWN,down);
            stage.addEventListener(MouseEvent.MOUSE_UP,up);
            stage.addEventListener(MouseEvent.MOUSE_MOVE,_move);

        }
        private function EnterFrame(e:Event):void
        {
            camera.render();
        }
        private function down(event:MouseEvent):void
        {
            isDragging = true;
        }
        private function up(event:MouseEvent):void
        {
            isDragging = false;
        }
        private function _move(event:MouseEvent):void
        {
            if (!isDragging)
            
                return;
                var deltaX:int = lastX-event.stageX;
                var deltaY:int = lastY-event.stageY;
                
                lastX = event.stageX;
                lastY = event.stageY;
                
                //cube.rotationZ +=deltaX*Math.PI /180;
                //cube.rotationY +=deltaY*Math.PI /180;
                
                var matrix:Matrix3D = cube.matrix;
                matrix.appendRotation(deltaX,new Vector3D(0,0,1));
                matrix.appendRotation(deltaY,new Vector3D(1,0,0));
                cube.matrix = matrix;
            
        
        }
    }
}