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

alternativa test01 : box, fillmaterial and "cellshading"

Alternativa test 01
Get Adobe Flash player
by IPFix 23 Oct 2012
/**
 * Copyright IPFix ( http://wonderfl.net/user/IPFix )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/e9Vb
 */

package {
    import flash.events.MouseEvent;
    
    import alternativ7.engine3d.core.Camera3D;
    import alternativ7.engine3d.core.Object3DContainer;
    import alternativ7.engine3d.core.View;
    import alternativ7.engine3d.materials.FillMaterial;
    import alternativ7.engine3d.primitives.Box;
    
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    
    import flash.filters.DropShadowFilter;
    
    [SWF(backgroundColor="#DDDDDD", width="465", height="465", frameRate="60")]
    public class HelloAlternativa3D extends Sprite {
        
        private var rootContainer:Object3DContainer = new Object3DContainer();
        
        private var camera:Camera3D;
        
        private var box:Box;
        
        public function HelloAlternativa3D() {
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            
            camera = new Camera3D();
            camera.view = new View(stage.stageWidth, stage.stageHeight);
            addChild(camera.view);
            addChild(camera.diagram);
            
            camera.rotationX = -120*Math.PI/180;
            camera.y = -800;
            camera.z = 400;
            rootContainer.addChild(camera);
            
            box = new Box(400, 400, 400, 1, 1, 1);
            var material:FillMaterial = new FillMaterial(0xEEEEEE, 1, 2,0xFFFFFF);
            box.setMaterialToAllFaces(material);
            rootContainer.addChild(box);
            
            box.filters = [new DropShadowFilter(0,0,0,1,4,4,3,1)];
            
            camera.view.width = stage.stageWidth;
            camera.view.height = stage.stageHeight;
            
            camera.render();
            
            stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
        }
        
        private function onMove(e:MouseEvent):void {
            box.rotationZ = (e.stageX/stage.stageWidth)*Math.PI;
            camera.y = -600-(e.stageY/stage.stageHeight)*400;
            camera.render();
        }
    }
}