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

Papeervisionの勉強(球を作成)

Get Adobe Flash player
by matsu4512 10 Jun 2009
    Embed
/**
 * Copyright matsu4512 ( http://wonderfl.net/user/matsu4512 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/owln
 */

package {
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    
    import org.papervision3d.lights.PointLight3D;
    import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
    import org.papervision3d.objects.primitives.Sphere;
    import org.papervision3d.view.BasicView;

    [SWF(backgroundColor=0x000000, width = 800, height=800)]

    public class Papervision8 extends Sprite
    {
        public function Papervision8()
        {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            
            //初期設定
            var world:BasicView = new BasicView();
            world.startRendering();
            addChild(world);
            
            //ライトの作成
            var light:PointLight3D = new PointLight3D();
            
            //マテリアルの作成
            //第一引数はライト
            var material:FlatShadeMaterial = new FlatShadeMaterial(light, 0xFF00FF);
            
            //第一引はマテリアル
            //2~4は半径、横のポリゴン分割数、縦のポリゴン分割数
            var sphere:Sphere = new Sphere(material, 400, 15, 15);
            
            world.scene.addChild(sphere);
            
            addEventListener(Event.ENTER_FRAME, function():void{
                sphere.rotationY -= (stage.mouseX - 400)/100;
                sphere.rotationX -= (stage.mouseY - 400)/100;
            });
        }
    }
}