Menu
Samaritan's Purse

CAMERA MOVE

Camera Move

CODE

´╗┐package
{
    import flash.events.KeyboardEvent;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.ui.Keyboard;

    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.objects.primitives.Plane;
    import org.papervision3d.view.BasicView;

    public class Papervision3DCameraMove extends BasicView
    {
        private var field :TextField;

        public function Papervision3DCameraMove()
        {
            super(640, 480, true, false, "Free");

            camera.z = 0;

            var object :Plane = new Plane(new ColorMaterial(0xff0000));
            object.z = 1000;
            scene.addChild(object);

            var object2 :Plane = new Plane(new ColorMaterial(0x00ff00));
            object2.z = 2000;
            scene.addChild(object2);

            field                 = new TextField();
            field.autoSize         = TextFieldAutoSize.LEFT;
            field.defaultTextFormat = new TextFormat("verdana");
            field.selectable        = false;
            addChild(field);

            stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);

            singleRender();
            instructions();
        }

        private function handleKeyDown(e:KeyboardEvent):void
        {
            switch (e.keyCode) {
                case Keyboard.ENTER:
                    camera.x = 0;
                    camera.y = 0;
                    camera.z = 0;
                    break;
                case "Q".charCodeAt():
                    camera.moveRight(10);
                    break;
                case "A".charCodeAt():
                    camera.moveLeft(10);
                    break;
                case "W".charCodeAt():
                    camera.moveUp(10);
                    break;
                case "S".charCodeAt():
                    camera.moveDown(10);
                    break;
                case "E".charCodeAt():
                    camera.moveForward(10);
                    break;
                case "D".charCodeAt():
                    camera.moveBackward(10);
                    break;
            }

            singleRender();
            instructions();
        }

        private function instructions():void
        {
            field.text = "Click\tStart"
                + "\nEnter\tReset"
                + "\nQ\t\tCamera Move Right"
                + "\nA\t\tCamera Move Left"
                + "\nW\t\tCamera Move Up"
                + "\nS\t\tCamera Move Down"
                + "\nE\t\tCamera Move Forward"
                + "\nD\t\tCamera Move Backward"
                + "\n\nCamera:"
                + "\nX:\t" + camera.x
                + "\nY:\t" + camera.y
                + "\nZ:\t" + camera.z;
        }
    }
}

Download