flash on 2011-5-16

by yama3
♥0 | Line 48 | Modified 2011-05-16 17:39:07 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;
    import flash.net.*;
    import flash.filters.*;
    import flash.text.*;
    
    public class FlashTest extends MovieClip {
        public function FlashTest() {
            addFrameScript(0, func);            
        }
        
        public function func():void {
            
            import org.papervision3d.view.BasicView;
            import org.papervision3d.materials.shadematerials.*;
            import org.papervision3d.objects.primitives.*;
            import org.papervision3d.lights.*;
            
            var world:BasicView = new BasicView();
            world.startRendering();
            addChild(world);
            
            var light:PointLight3D = new PointLight3D();
            
            var material:FlatShadeMaterial = new FlatShadeMaterial(light, 0xffff00);
            
            var sphere:Sphere = new Sphere(material, 400, 100, 100);
            
            world.scene.addChild(sphere);
            
            var rot2:Number = 0;
            addEventListener(Event.ENTER_FRAME, function():void {
                var targetRot2:Number = (mouseX / stage.stageWidth) * 360;
                rot2 += (targetRot2-rot2)*0.02;
                
                world2.camera.x = 1000 * Math.sin(rot2 * Math.PI / 180);
                world2.camera.z = 1000 * Math.cos(rot2 * Math.PI / 180);
                
                sphere2.rotationY -= 0.25;
            })
            
            addEventListener(Event.ENTER_FRAME, function():void {
                sphere.rotationY += 1;
            })
            
            var world2:BasicView = new BasicView();
            world2.startRendering();
            addChild(world2);
            var light2:PointLight3D = new PointLight3D();
            
            var material2:FlatShadeMaterial = new FlatShadeMaterial(light, 0xffff00);
            
            var sphere2:Sphere = new Sphere(material2, 400, 100, 100);
            sphere2.x = 30;
            
            world2.scene.addChild(sphere2);
            
            addEventListener(Event.ENTER_FRAME, function():void {
                sphere2.rotationY+=1;
            })
        }

    }
}