Native3D

by fakestar0826
♥0 | Line 37 | Modified 2011-01-14 00:31:43 | MIT License
play

ActionScript3 source code

/**
 * Copyright fakestar0826 ( http://wonderfl.net/user/fakestar0826 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/htQp
 */

package {
    import flash.geom.Point;
    import flash.events.Event;
    import flash.display.Shape;
    import flash.display.Sprite;
    
    [SWF(backgroundColor = 0xCCFFCC)]
    public class FlashTest extends Sprite {
        
        private var _shape:Shape;
        private var _n:Number = 0;
        
        public function FlashTest() {
            // write as3 code here..
            
            //消失点の設定
            root.transform.perspectiveProjection.projectionCenter = new Point(stage.stageWidth / 2, stage.stageHeight / 2);
            
            _shape = new Shape();
            _shape.graphics.beginFill(0xFF0000);
            _shape.graphics.drawRect(-100, -100, 200, 200);
            _shape.x = stage.stageWidth / 2;
            _shape.y = stage.stageHeight / 2;
            addChild(_shape);
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
            
            stage.addEventListener(Event.RESIZE, onResize);
        }
        
        private function onEnterFrame(e:Event):void
        {
            //Y軸を中心とした回転
            //_shape.rotationY += 2;
            _shape.x = mouseX;
            _shape.y = mouseY;
            _shape.z = 10000 + Math.sin(_n += 0.1) * 10000;
        }
        
        /**
         * リサイズ処理。wonderflでは意味ないかな。
         */
        private function onResize(e:Event):void
        {
            root.transform.perspectiveProjection.projectionCenter = new Point(stage.stageWidth / 2, stage.stageHeight / 2);
            
            if(_shape != null)
            {
                _shape.x = stage.stageWidth / 2;
                _shape.y = stage.stageHeight / 2;
            }

        }

    }
}

Forked