Beautifl - Flash Gallery

Thumbnail : 花時計
花時計
hacker_cobulht0 2010-02-09 see code comments

再生するにはFlash Playerが必要です。デスクトップのブラウザでご覧ください。

package {//papervision3d練習とか
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;

	import org.papervision3d.view.*;
	import org.papervision3d.objects.*;
	import org.papervision3d.objects.primitives.*;
	import org.papervision3d.cameras.*;
	import org.papervision3d.materials.*;
	import org.papervision3d.core.effects.view.*;
	
	import org.papervision3d.typography.*;
    import org.papervision3d.typography.fonts.*;
    import org.papervision3d.materials.special.*;

	import org.papervision3d.core.geom.*;
	import org.papervision3d.core.geom.renderables.Vertex3D;
	

	[SWF(width = "465", height = "465", backgroundColor = 0xffffff, frameRate = "60")]

	public class clock1 extends BasicView {

		private var rootNode  : DisplayObject3D;
		private var myArray1:Array;
		private var myArray2:Array;
		private var myArray3:Array;	
		
		private var rot:Number=0;
		private var letterMat   : Letter3DMaterial;
		
		public function clock1() {Wonderfl.capture_delay(10);
			rootNode = new DisplayObject3D();
			scene.addChild( rootNode );

			myArray1=new Array();
			myArray2=new Array();
			myArray3=new Array();
					
			 for (var j:int = 0; j < 6; j++) {  
				var bmpData:BitmapData = new BitmapData(80,300,true,0x00000000);
				var shapes:petal=new petal(j);
				bmpData.draw(shapes);
				
				var material: BitmapMaterial = new BitmapMaterial(bmpData);
				material.smooth = true;
				material.oneSide = false;
				
				var planeObj:DisplayObject3D = new Plane( material, 80, 300, 0, 0);
				planeObj.z=j*20;
				
				rootNode.addChild( planeObj );
				myArray1.push(planeObj);
			 }
			 
			var letterStr:Array=["12","1","2","3","4","5","6","7","8","9","10","11"];
			letterMat = new Letter3DMaterial(0xE3DA37,1);
			  for (var q:uint = 0; q < 12; q++) {                
                myArray2[q] = new Text3D(letterStr[q], new HelveticaBold(), letterMat);
				var rad=30*q;
				myArray2[q].scaleX=myArray2[q].scaleY=0.5;
				myArray2[q].x=150*Math.sin(rad*Math.PI/180);
				myArray2[q].y=150*Math.cos(rad*Math.PI/180);
				myArray2[q].z=-100;
                rootNode.addChild(myArray2[q]);
            }
			
			var arrheight2:Array=[60,120,150];
			for (var qq:uint = 0; qq < 3; qq++) {				
				var height2=arrheight2[qq];
				var bmpData2:BitmapData = new BitmapData(10,height2,true,0x00000000);
				var shapes2:hands=new hands(height2);
				bmpData2.draw(shapes2);
				var material2: BitmapMaterial = new BitmapMaterial(bmpData2);
				var planeObj2:DisplayObject3D = new Plane( material2, 10, height2, 0, 0);
				planeObj2.z=-20;		
				
				rootNode.addChild( planeObj2 );
				myArray3.push(planeObj2);
			}
			
			for (var i:uint = 0; i < planeObj2.geometry.vertices.length;i++){
			var v:Vertex3D = myArray3[0].geometry.vertices[i];
			var v2:Vertex3D = myArray3[1].geometry.vertices[i];
			var v3:Vertex3D =myArray3[2] .geometry.vertices[i];
			v.y-=30;
			v2.y-=60;
			v3.y-=75;
			}
			
			camera.z = 0;
			camera.y = 0;
			camera.zoom = 0;
			//camera.focus = 10;	

			stage.addEventListener(Event.ENTER_FRAME, loop);
		}
		
		private function loop( event:Event ):void {
			
			var dd:Date = new Date();
			myArray3[0].rotationZ = dd.hours * -30-180;
			myArray3[1].rotationZ = dd.minutes * -6-180;
			myArray3[2].rotationZ = dd.seconds * -6-180;
			
			if(myArray1[1].rotationZ<30){myArray1[1].rotationZ+=1;}
			if(myArray1[2].rotationZ<60){myArray1[2].rotationZ+=1;}
			if(myArray1[3].rotationZ<90){myArray1[3].rotationZ+=1;}
			if(myArray1[4].rotationZ<120){myArray1[4].rotationZ+=1;}
			if(myArray1[5].rotationZ<150){myArray1[5].rotationZ+=1;}
			
			if(camera.z>-400){camera.z-=1;}
			if(camera.zoom<50){camera.zoom+=0.5}
	
			rot+=0.2;
			camera.y=200*Math.cos(rot*Math.PI/180);
			camera.x=400*Math.sin(rot*Math.PI/180);

			// 再レンダリング
			singleRender();
		}
	}
}

import flash.display.Sprite;import flash.display.Shape;
import flash.display.GradientType; 
import flash.geom.Matrix;
class petal extends Sprite{
	private var arr:Array=[
						   			[0xFB5E79,0xFED78A,0xFF917A,0xFF917A,0xFED78A,0xFB5E79],
									[0xFF6975,0xFFB403,0xE3DA37,0xE3DA37,0xFFB403,0xFF6975],
									[0xFED78A,0xFB5E79,0xFF917A,0xFF917A,0xFB5E79,0xFED78A],
									[0xFFB403,0xFF6975,0xE3DA37,0xE3DA37,0xFF6975,0xFFB403],
									[0xFCC4AD,0xFB5E79,0xFED78A,0xFED78A,0xFB5E79,0xFCC4AD],
									[0xFFB403,0xE3DA37,0xFF6975,0xFF6975,0xE3DA37,0xFFB403]									
						   		]
public function petal(arg1:Number){
					var slctArr:Array=arr[arg1];
					var _sp:Shape = new Shape();
					var rot:Number = 2 * Math.PI * (90 / 360);
					var gbm:Matrix = new Matrix(); 
					gbm.createGradientBox(40, 300, rot, 0, 0); 
					_sp.graphics.beginGradientFill(GradientType.LINEAR, [slctArr[0],slctArr[1],slctArr[2],slctArr[3],slctArr[4],slctArr[5]], [1,1,1,1,1,1], [0, 60,127,128,220, 255], gbm);
					
					//_sp.graphics.drawCircle(40,20,20);
					_sp.graphics.moveTo(20,40);
					_sp.graphics.curveTo(20,0,40,0);
					_sp.graphics.curveTo(60,0,60,40);					
					
					_sp.graphics.moveTo(20,40);									
					_sp.graphics.lineTo(60,40);
					_sp.graphics.lineTo(50,120);									
					_sp.graphics.lineTo(30,120);
					
					//_sp.graphics.drawCircle(40,140,10);
					_sp.graphics.moveTo(30,120);
					_sp.graphics.curveTo(30,140,40,140);
					_sp.graphics.curveTo(50,140,50,120);					
					
					//_sp.graphics.drawCircle(40,160,10);
					_sp.graphics.moveTo(30,180);
					_sp.graphics.curveTo(30,160,40,160);
					_sp.graphics.curveTo(50,160,50,180);	
					
					_sp.graphics.moveTo(30,180);									
					_sp.graphics.lineTo(50,180);
					_sp.graphics.lineTo(60,260);									
					_sp.graphics.lineTo(20,260);
					
					_sp.graphics.moveTo(20,260);
					_sp.graphics.curveTo(20,300,40,300);
					_sp.graphics.curveTo(60,300,60,260);
					//_sp.graphics.drawCircle(40,280,20);
					_sp.graphics.endFill();						
					addChild(_sp);			
}
}

class hands extends Sprite{
public function hands(arg1:Number){
		var _sp:Shape = new Shape();
		_sp.graphics.lineStyle(2,0xFF4F5A)
		_sp.graphics.moveTo(0,10);
		_sp.graphics.lineTo(5,0);
		_sp.graphics.lineTo(10,10);
		_sp.graphics.lineTo(0,10);
		_sp.graphics.lineTo(10,20);
		_sp.graphics.moveTo(10,10);
		_sp.graphics.lineTo(0,20);
		_sp.graphics.lineTo(10,20);
		
		_sp.graphics.lineTo(5,arg1);
		_sp.graphics.lineTo(0,20);
		addChild(_sp)
	}
}