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

PV3D練習

Get Adobe Flash player
by hacker_cobulht0 06 Jul 2012
    Embed
/**
 * Copyright hacker_cobulht0 ( http://wonderfl.net/user/hacker_cobulht0 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/5xe6
 */

/*
久々にpapervision3d
右上のボタンでズーム
まわりをつかんだり
てっぺんのボタンをおしたり
*/
package {
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    
    import org.papervision3d.core.math.Matrix3D;
    import org.papervision3d.core.math.Number3D;
    import org.papervision3d.render.QuadrantRenderEngine;
    import org.papervision3d.view.BasicView;
    import org.papervision3d.core.effects.view.ReflectionView;
    
    import org.papervision3d.materials.*;
    import org.papervision3d.objects.*;
    import org.papervision3d.materials.utils.*;
    import org.papervision3d.objects.primitives.*;
    import org.papervision3d.events.InteractiveScene3DEvent;
    
    
    import org.papervision3d.scenes.*;
    import org.papervision3d.cameras.*;
    
    
    
    import caurina.transitions.Tweener; 

    [SWF(width = "465", height = "465", backgroundColor = 0xFFFFFF, frameRate = "30")]

    public class Main extends ReflectionView {
        
        public var bg:back_ground=new back_ground();
        
        private var rootNode :DisplayObject3D= new DisplayObject3D();
        private var _DICE;
        private var miniBT;
        private var clockH:DisplayObject3D;
        private var clockM:DisplayObject3D;
        private var clockS:DisplayObject3D;
        private var floralList:Array=new Array();
        
        public var mcp:Point = new Point();
        
        private var _zmBt:zmBt=new zmBt();
        private var zmstts:String="small";
         
            
        public function Main() {
            super(0,0,true,true);
            funcReady1();
        }
        
        public function funcReady1() {
            //背景----------------------------------------------------------------------------------------------------
            addChildAt(bg,0);            
            
            surfaceHeight = -150;
            viewportReflection.alpha = 0.15;
            
            scene.addChild( rootNode );
            //_DICE----------------------------------------------------------------------------------------------------
                var bmpData:BitmapData = new BitmapData(100,100,true,0x00FFFFFF);
                var shapes:diceFront=new diceFront();
                bmpData.draw(shapes);
                var mat1: BitmapMaterial = new BitmapMaterial(bmpData);
                mat1.interactive = true;
                mat1.smooth = true;
                
                var bmpData2:BitmapData = new BitmapData(100,100,true,0x88FFFFFF);
                var shapes2:diceSide=new diceSide();
                bmpData2.draw(shapes2);
                var mat2: BitmapMaterial = new BitmapMaterial(bmpData2,true);
                mat2.interactive = true;
                mat2.smooth = true;
                
                
                var bmpData3:BitmapData = new BitmapData(50,50,true,0x00FFFFFF);
                var shapes3:miniBTFront=new miniBTFront();
                bmpData3.draw(shapes3);
                var mat3: BitmapMaterial = new BitmapMaterial(bmpData3);
                mat3.interactive = true;
                mat3.smooth = true;
                
                var materialsList:MaterialsList = new MaterialsList({
                    front: mat2,
                    back: mat1,
                    right: mat2,
                    left: mat2,
                    top: mat2,
                    bottom: mat3
                });
                
                _DICE = new Cube(materialsList, 100, 100, 100, 1, 1, 1);
                _DICE.name="_Dice";
                
                rootNode.addChild(_DICE);
            
                _DICE.y=0;        
                _DICE.x=0;
                _DICE.z=0;
                
            //miniBT----------------------------------------------------------------------------------------------------
                var bmpData4:BitmapData = new BitmapData(50,50,true,0x00FFFFFF);
                var shapes4:miniBTSide=new miniBTSide();
                bmpData4.draw(shapes4);
                var mat4: BitmapMaterial = new BitmapMaterial(bmpData4);
                mat4.interactive = true;
                mat4.smooth = true;
                
                var materialsList2:MaterialsList = new MaterialsList({
                    front: mat4,
                    back: mat4,
                    right: mat4,
                    left: mat4,
                    top: mat3,
                    bottom: mat3
                });
                miniBT = new Cube(materialsList2, 50, 50, 20, 1, 1, 1);                
                miniBT.name="miniBT";
                
                rootNode.addChild(miniBT);
            
                miniBT.y=_DICE.y+60;        
                miniBT.x=_DICE.x+0;
                miniBT.z=_DICE.z+0;
                miniBT.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS,funcRelease);
                
            //leg----------------------------------------------------------------------------------------------------
                var leg1:Sphere = new Sphere(mat2,10,10,10);
                leg1.z=_DICE.z-40;
                leg1.y=_DICE.y-60;        
                leg1.x=_DICE.x-40;
                rootNode.addChild( leg1 );
                var leg2:Sphere = new Sphere(mat2,10,10,10);
                leg2.z=_DICE.z-40;
                leg2.y=_DICE.y-60;        
                leg2.x=_DICE.x+40;
                rootNode.addChild( leg2 );
                var leg3:Sphere = new Sphere(mat2,10,10,10);
                leg3.z=_DICE.z+40;
                leg3.y=_DICE.y-60;        
                leg3.x=_DICE.x-40;
                rootNode.addChild( leg3 );
                var leg4:Sphere = new Sphere(mat2,10,10,10);
                leg4.z=_DICE.z+40;
                leg4.y=_DICE.y-60;        
                leg4.x=_DICE.x+40;
                rootNode.addChild( leg4 );
                
            //clockList----------------------------------------------------------------------------------------------------
                var bmpData5:BitmapData = new BitmapData(10,100,true,0x00FFFFFF);
                var shapes5:clockHand=new clockHand(10,30,0x71BC78);
                bmpData5.draw(shapes5);
                var mat5: BitmapMaterial = new BitmapMaterial(bmpData5);
                mat5.interactive = true;
                mat5.smooth = true;
                clockH = new Plane(mat5);
                rootNode.addChild( clockH );
                clockH.y=_DICE.y+0;
                clockH.x=_DICE.x+0;
                clockH.z=_DICE.z-55;
                
                var bmpData6:BitmapData = new BitmapData(10,100,true,0x00FFFFFF);
                var shapes6:clockHand=new clockHand(10,40,0x71BC78);
                bmpData6.draw(shapes6);
                var mat6: BitmapMaterial = new BitmapMaterial(bmpData6);
                mat6.interactive = true;
                mat6.smooth = true;
                clockM = new Plane(mat6);
                rootNode.addChild( clockM );
                clockM.y=_DICE.y+0;
                clockM.x=_DICE.x+0;
                clockM.z=_DICE.z-55;
                
                var bmpData7:BitmapData = new BitmapData(2,100,true,0x00FFFFFF);
                var shapes7:clockHand=new clockHand(2,50,0x199EBD);
                bmpData7.draw(shapes7);
                var mat7: BitmapMaterial = new BitmapMaterial(bmpData7);
                mat7.interactive = true;
                mat7.smooth = true;
                clockS = new Plane(mat7);
                rootNode.addChild( clockS );
                clockS.y=_DICE.y+0;
                clockS.x=_DICE.x+0;
                clockS.z=_DICE.z-57;
                
                var bmpData8:BitmapData = new BitmapData(100,100,true,0x00C5E384);
                var shapes8:_COVER=new _COVER();
                bmpData8.draw(shapes8);
                var mat8: BitmapMaterial = new BitmapMaterial(bmpData8);
                mat8.interactive = true;
                mat8.smooth = true;
                var cv = new Plane(mat8);
                rootNode.addChild( cv );
                cv.y=_DICE.y+0;
                cv.x=_DICE.x+0;
                cv.z=_DICE.z-60;
                
                
            //floralList----------------------------------------------------------------------------------------------------
            
                for (var q:int=0; q < 25; q++) {
                    var bmdF:BitmapData = new BitmapData(25,25,true,0x00FFFFFF);
                    var shF:fPT=new fPT();
                    bmdF.draw(shF);
                    var matF: BitmapMaterial = new BitmapMaterial(bmdF);
                    matF.interactive = true;
                    matF.smooth = true;
                    var pt = new Plane(matF);
                    rootNode.addChild( pt );
                    pt.y=_DICE.y+0;
                    pt.x=_DICE.x+0;
                    pt.z=_DICE.z+0;
                    floralList.push(pt);
                }

                
                
                //----------------------------------------------------------------------------------------------------
                camera.z = -1000;
                camera.zoom = 100;
                camera.focus = 15;                
            
                
                bg.addEventListener(Event.ENTER_FRAME, loop);
                bg.addEventListener(MouseEvent.MOUSE_DOWN, startRotation);
                
                addChild(_zmBt);
                _zmBt.x=400;
                _zmBt.y=10;
                _zmBt.addEventListener(MouseEvent.MOUSE_UP,click_zmBt);
        }
        
        
        
        
        
        private function funcRelease(ev:InteractiveScene3DEvent):void {
            var t_C:Cube=ev.target as Cube;
            Tweener.addTween(t_C, {y:_DICE.y+45, time:0.5});
            Tweener.addTween(t_C, {y:_DICE.y+60, time:1, delay:0.6,transition:"easeOutQuad"});
            
            for (var q:int=0; q < floralList.length; q++) {
                var pt=floralList[q];
                var px:int=Math.floor (Math.random () * 400)-200;
                var py:int=Math.floor (Math.random () * 400)-200;
                var pz:int=Math.floor (Math.random () * 400)-1000;
                Tweener.addTween(pt, {x:px, y:py,z:pz,time:1, delay:0.02*q,transition:"easeOutQuad", onComplete:function() { this.x=this.y=this.z=0;}});
            }
        }    
        
        
        private function startRotation(ev):void{
            bg.addEventListener(MouseEvent.MOUSE_UP, endDrag);
            bg.addEventListener(Event.MOUSE_LEAVE, endDrag);
            bg.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
            
            mcp.x = mouseX;
            mcp.y = mouseY;
        }
        private function endDrag(ev):void{
            bg.removeEventListener(MouseEvent.MOUSE_UP, endDrag);
            bg.removeEventListener(Event.MOUSE_LEAVE, endDrag);
            bg.removeEventListener(MouseEvent.MOUSE_MOVE, onMove);
        }
        private function onMove(ev):void{            
            rootNode.rotationX -= (ev.stageY - mcp.y);
            rootNode.rotationY -= (ev.stageX - mcp.x);
            
            mcp.x = mouseX;
            mcp.y = mouseY;
        }
        
        //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        private function loop( event:Event ):void {
            var dd:Date = new Date();
            clockH.rotationZ = dd.hours * -30-180;
            clockM.rotationZ = dd.minutes * -6-180;
            clockS.rotationZ = dd.seconds * -6-180;
            
            singleRender();
        }    
        //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         private function click_zmBt(ev):void{
            if(zmstts=="small"){
                _zmBt.scaleX=_zmBt.scaleY=0.5;
                _zmBt.x=420;
                zmstts="big";
                Tweener.addTween(camera,{zoom:150, time:1, transition:"easeOutQuad"});
            }else if(zmstts=="big"){
                _zmBt.scaleX=_zmBt.scaleY=1;
                _zmBt.x=400;
                Tweener.addTween(camera,{zoom:100, time:1, transition:"easeOutQuad"});
                zmstts="small";
            }
         }
    }
}





















//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import flash.display.*;
import flash.filters.GlowFilter;

//BackGround
class back_ground extends Sprite{    
    private var arr:Array=[0x7DCCB6,0x9ADDCC];
public function back_ground(){
    for(var j:int=0; j < 232; j++){
        this.graphics.beginFill(arr[j%2],1);
        this.graphics.drawRect(j*2,0,2,465);
        this.graphics.endFill();        
    }
}
}

//_DICE--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
class diceDesign extends Sprite{
public function diceDesign( ){
    var arr:Array=[0xFCDC6B,0xFCE983,0xF0E991,0xEDEABF,0xC5E285,0xA8E39F,0x9FE2BF,0x77DEE7,0x9BCEEB,0xC5D0E6,0xAEADD7,0xCDA4DE,0xE6A8D7,0xFDD7E4,0xFDBDB4,0xFFCFAB,0xFED8B4,0xFBE7B5];
    var bmp:BitmapData = new BitmapData(465, 465, false, 0xffffff);
    var sh:Sprite = new Sprite();
    for(var j:int=0; j < 31; j++){
        var cl=j % arr.length;
        sh.graphics.beginFill(arr[cl]);
        sh.graphics.drawRect(0,j*15,465,15);
        sh.graphics.endFill();
        
        var sh2:Shape=new Shape();
        sh.addChild(sh2);
        sh2.graphics.beginFill(arr[cl],0.5);
        sh2.graphics.drawRect(j*15,0,15,465);
        sh2.graphics.endFill();
    }
    bmp.draw(sh);
    addChild(new Bitmap(bmp))
}
}


class diceFront extends Sprite{
public function diceFront(){
        var _sp1:diceDesign = new diceDesign();
        addChild(_sp1);
        
        var _sp2:Sprite = new Sprite();
        _sp2.graphics.beginFill(0x71BC78,.5);
        _sp2.graphics.drawCircle(50,50,46);
        _sp2.graphics.beginFill(0xFFFFFF);
        _sp2.graphics.drawCircle(50,50,39);
        _sp2.graphics.endFill();
        addChild(_sp2);
        
        var _sp3:drawChick = new drawChick();
        _sp3.x=36;
        _sp3.y=40;
        _sp3.scaleX=_sp3.scaleY=1.2;
        addChild(_sp3);
                
        mouseChildren = false;        
}}

class diceSide extends Sprite{
public function diceSide(){
        var _sp1:diceDesign = new diceDesign();
        addChild(_sp1);
        mouseChildren = false;
}}
//drawChick--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
class drawChick extends Sprite{
    private var head:Sprite=new Sprite();
    private var body:Sprite=new Sprite();
    private var scarf:Sprite=new Sprite();
    public var foot:Sprite=new Sprite();
    
public function drawChick(){
        head.graphics.beginFill(0xFCD975);
        head.graphics.drawCircle(0,0,10);//head
        head.graphics.endFill();
        var head_1:Sprite = new Sprite();
        head_1.graphics.beginFill(0x1DACD6);//eye
        head_1.graphics.drawCircle(-1,-1,2);
        head_1.graphics.endFill();
        head_1.graphics.beginFill(0xFFB653);//mouse
        head_1.graphics.drawEllipse(-15,-2,7,4);        
        head_1.graphics.endFill();
        head.addChild(head_1);
        addChild(head);
        
        body.graphics.beginFill(0xFCD975);//body
        body.graphics.drawEllipse(2,2,30,20);
        body.graphics.endFill();
        var body_1:Sprite = new Sprite();
        body_1.graphics.beginFill(0xFCD975);//teil
        body_1.graphics.moveTo(20,5);
        body_1.graphics.lineTo(35,-1);
        body_1.graphics.lineTo(32,13);
        body_1.graphics.endFill();
        body.addChild(body_1);
        addChild(body);    
        
        foot.graphics.lineStyle(2,0xFFB653);//foot
        foot.graphics.moveTo(18,23);
        foot.graphics.lineTo(18,25);
        foot.graphics.moveTo(18,25);
        foot.graphics.lineTo(15,30);
        foot.graphics.moveTo(18,25);
        foot.graphics.lineTo(12,28);
        foot.graphics.moveTo(18,25);
        foot.graphics.lineTo(10,25);        
        foot.graphics.endFill();
        
        addChild(foot);    
        
        scarf.graphics.beginFill(0xFD7C6E);
        scarf.graphics.drawEllipse(-5,8,14,3);
        scarf.graphics.endFill();    
        scarf.rotation=-40;        
        var scarf_1:Sprite = new Sprite();    
        scarf_1.graphics.beginFill(0xFD7C6E);
        scarf_1.graphics.drawEllipse(0,0,15,5);
        scarf_1.graphics.endFill();    
        scarf_1.rotation=-60;
        scarf_1.x=5;scarf_1.y=8;        
        var scarf_2:Sprite = new Sprite();    
        
        scarf_2.graphics.beginFill(0xFD7C6E);
        scarf_2.graphics.drawEllipse(0,0,15,5);
        scarf_2.graphics.endFill();    
        scarf_2.rotation=-20;
        scarf_2.x=5;scarf_2.y=8;        
        scarf.addChild(scarf_2);
        scarf.addChild(scarf_1);
        addChild(scarf);
    }
}





//miniBT--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
class miniBTFront extends Sprite{
public function miniBTFront(){
        this.graphics.beginFill(0xC5E384);
        this.graphics.drawRoundRect(0,0,50,50,5);
        this.graphics.endFill();
        filters = [ new GlowFilter( 0xFFFF99, 1, 20, 20, 1,2,true ) ] ;
    
        var _pic:drawFlower=new drawFlower(0xffffff);
        _pic.alpha=0.8;
        _pic.scaleX=_pic.scaleY=5;
        _pic.x=25;                            
        _pic.y=25;
        addChild(_pic);
}}
class miniBTSide extends Sprite{
public function miniBTSide(){
        this.graphics.beginFill(0xFF9999);
        this.graphics.drawRoundRect(0,0,50,50,5);
        this.graphics.endFill();            
        filters = [ new GlowFilter( 0xFD7C6E, 1, 15, 15, 1,2,true ) ] ;
}}
class drawFlower extends Sprite{
public function drawFlower(colors){    
            for(var j:int=0; j < 5; j++){
                    var fl_sp:Sprite = new Sprite();                    
                    fl_sp.graphics.beginFill(colors);
                    fl_sp.graphics.drawEllipse(-1,0.5,2,4);                    
                    fl_sp.graphics.endFill();                        
                    fl_sp.rotation=j*72+180;
                    addChild(fl_sp);
            }        
    }
}





//clockList----------------------------------------------------------------------------------------------------
class clockHand extends Sprite{
public function clockHand (w,h,col){
        var sp:Sprite=new Sprite();
            sp.graphics.beginFill(col);
            sp.graphics.drawEllipse(0,95-h,w,h);                
            sp.graphics.endFill();
            addChild(sp);
    }
}





//_COVER----------------------------------------------------------------------------------------------------
class _COVER extends Sprite{
public function _COVER (){
        this.graphics.beginFill(0xC5E384);
        this.graphics.drawCircle(50,50,46);
        this.graphics.drawCircle(50,50,40);
        this.graphics.endFill();
        filters = [ new GlowFilter( 0xFFFF99, 1, 20, 20, 1,2,false ) ] ;
    }
}


//_COVER----------------------------------------------------------------------------------------------------
class fPT extends Sprite{
public function fPT (){
        var _pic:drawFlower=new drawFlower(0xffffff);
        _pic.scaleX=_pic.scaleY=2;
        _pic.x=12;                            
        _pic.y=12;
        addChild(_pic);
        filters = [ new GlowFilter( 0xFFFF99, 1, 5, 5, 1,1,false ) ] ;
    }
}


//zmBt----------------------------------------------------------------------------------------------------
class zmBt extends Sprite{
public function zmBt (){
        var _pic:drawFlower=new drawFlower(0xffffff);
        _pic.scaleX=_pic.scaleY=4;
        _pic.x=25;                            
        _pic.y=25;
        addChild(_pic);
        this.graphics.beginFill(0xFFFFFF,0.5);
        this.graphics.drawCircle(25,25,25);
        this.graphics.endFill();
        this.buttonMode = true; 
    }
}