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

Puzzle

papervision3d練習その2
package {//papervision3d練習その2
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	import org.papervision3d.materials.*;
	import org.papervision3d.objects.*;
	import org.papervision3d.materials.utils.*;
	import org.papervision3d.objects.primitives.*;
	import org.papervision3d.view.*;
	
	import org.papervision3d.events.InteractiveScene3DEvent;
	import org.papervision3d.core.utils.InteractiveSceneManager;
	import org.papervision3d.core.utils.Mouse3D;
	
	import org.papervision3d.typography.*;
    import org.papervision3d.typography.fonts.*;
    import org.papervision3d.materials.special.*;

	import org.papervision3d.core.geom.*;
	
	import caurina.transitions.Tweener; 

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

	public class neunPuzzle extends BasicView {

		private var rootNode  : DisplayObject3D;	
		private var rot:Number=0;
		
		private var _sArray=[0,1,2,3,4,8,6,7,5]
		private var myArray=[
						[99,99,99,99,99],
						[99,0,1,2,99],
						[99,3,4,5,99],
						[99,6,7,8,99],
						[99,99,99,99,99]
						];
		private var myArray_pos:Object={nineY:98, nineX:98, ue:98, st:98, mg:98, hd:98};
		private var _BlockList:Array=new Array();

		private var ckClick:Boolean=false;
		
		//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
		private var rndArray:Array=[1000,-1000];
		private var ckClear:Boolean=false;
			
		public function neunPuzzle() {
			super(0,0,true,true);
			//ShuffleArray
			var sa = _sArray.length;
			while (sa--) {
			var j = Math.floor(Math.random()*(sa+1));
			var t = _sArray[sa];
			_sArray[sa] = _sArray[j];
			_sArray[j] = t;
			}
			funcReady1();
		}
		
		public function funcReady1() {
			//背景----------------------------------------------------------------------------------------------------
			var bg:back_ground=new back_ground();
			addChildAt(bg,0);
			
			rootNode = new DisplayObject3D();
			scene.addChild( rootNode );	
			var color1:Array=[0xFB5E79,0xFE8D8D,0xFB5E79,0xFF9575,0xDD4969,0xFF9575,0xFB5E79,0xFE8D8D];
			
			for (var j:int = 0; j < 9; j++) {
				if(j!=8){
				var bmpData:BitmapData = new BitmapData(50,50,true,0x00000000);
				var shapes:drawBlockFront=new drawBlockFront(j,String(j+1));
				bmpData.draw(shapes);
				var mat1: BitmapMaterial = new BitmapMaterial(bmpData);
				mat1.interactive = true;
				mat1.smooth = true;
				
				var bmpData2:BitmapData = new BitmapData(50,50,true,0x00000000);
				var shapes2:drawBlockSide=new drawBlockSide(j);
				bmpData2.draw(shapes2);
				var mat2: BitmapMaterial = new BitmapMaterial(bmpData2);
				mat2.interactive = true;
				mat2.smooth = true;
				
				var materialsList:MaterialsList = new MaterialsList({
				front: mat2,
				back: mat1,
				right: mat2,
				left: mat2,
				top: mat2,
				bottom: mat2
				});
				var cube = new Cube(materialsList, 50, 50, 50, 1, 1, 1);
				cube.name=j;//"Cube"+String(j+1);
				
				rootNode.addChild( cube);				
				_BlockList.push(cube);
				}
			}
			funcReady2();
		}
		
		public function funcReady2() {
			for (var j:uint=0; j < 9; j++) {
				myArray[(Math.floor(j/3))+1][(j%3)+1]=_sArray[j];
				if(_sArray[j]!=8){		
				_BlockList[_sArray[j]].y=Math.floor(j/3)*-60+60;				
				_BlockList[_sArray[j]].x=j%3*60-60;
				_BlockList[_sArray[j]].addEventListener(InteractiveScene3DEvent.OBJECT_PRESS,funcRelease);
				}else if(_sArray[j]==8){
					myArray_pos["nineY"]=(Math.floor(j/3))+1;
					myArray_pos["nineX"]=(j%3)+1;
				}
			}
			camera.z = -600;
			camera.zoom = 100;
			//camera.focus = 10;	
			ckAzimuth();
			stage.addEventListener(Event.ENTER_FRAME, loop);
		}
		
		private function funcRelease(e:InteractiveScene3DEvent):void {
			var t_C:Cube=e.target as Cube;
			var _move:Number;
			var yy:Number=myArray_pos["nineY"];
			var xx:Number=myArray_pos["nineX"];
			if(t_C.name==myArray_pos["ue"]&&ckClick==true){ckClick=false;
				_move=t_C.y-60;
								Tweener.addTween(t_C, {y:_move, time:0.6, transition:"easeOutBack"
								,onComplete:function(e){
									myArray[yy][xx]=t_C.name;
									myArray[yy-1][xx]=8;
									myArray_pos["nineY"]=yy-1;ckAzimuth();
								}
								});
								Tweener.addTween(camera,{y:-300, time:1, transition:"easeOutQuad"});
			}
			else if(t_C.name==myArray_pos["st"]&&ckClick==true){ckClick=false;
				_move=t_C.y+60;
								Tweener.addTween(t_C, {y:_move, time:0.6, transition:"easeOutBack"
								,onComplete:function(e){
									myArray[yy][xx]=t_C.name;
									myArray[yy+1][xx]=8;
									myArray_pos["nineY"]=yy+1;ckAzimuth();
								}
								});
								Tweener.addTween(camera,{y:300, time:1, transition:"easeOutQuad"});
			}
			else if(t_C.name==myArray_pos["hd"]&&ckClick==true){ckClick=false;
				_move=t_C.x+60;
								Tweener.addTween(t_C, {x:_move, time:0.6, transition:"easeOutBack"
								,onComplete:function(e){
									myArray[yy][xx]=t_C.name;
									myArray[yy][xx-1]=8;
									myArray_pos["nineX"]=xx-1;ckAzimuth();
								}
								});
								Tweener.addTween(camera,{x:-300, time:1, transition:"easeOutQuad"});
			}
			else if(t_C.name==myArray_pos["mg"]&&ckClick==true){ckClick=false;
				_move=t_C.x-60;
								Tweener.addTween(t_C, {x:_move, time:0.6, transition:"easeOutBack"
								,onComplete:function(e){
									myArray[yy][xx]=t_C.name;
									myArray[yy][xx+1]=8;
									myArray_pos["nineX"]=xx+1;ckAzimuth();
								}
								});
								Tweener.addTween(camera,{x:300, time:1, transition:"easeOutQuad"});
			}
			
		}
		
		private function ckAzimuth() {
			var _9y:Number=myArray_pos["nineY"];
			var _9x:Number=myArray_pos["nineX"];			
			if(myArray[_9y-1][_9x]==99){myArray_pos["ue"]=99}else{myArray_pos["ue"]=myArray[_9y-1][_9x]};
			if(myArray[_9y+1][_9x]==99){myArray_pos["st"]=99}else{myArray_pos["st"]=myArray[_9y+1][_9x]};
			if(myArray[_9y][_9x-1]==99){myArray_pos["hd"]=99}else{myArray_pos["hd"]=myArray[_9y][_9x-1]};
			if(myArray[_9y][_9x+1]==99){myArray_pos["mg"]=99}else{myArray_pos["mg"]=myArray[_9y][_9x+1]};
			ckGoal();			
		}
		private function ckGoal(){
			if(myArray[1][1]==0&&
			 	myArray[1][2]==1&&
				myArray[1][3]==2&&
				myArray[2][1]==3&&
				myArray[2][2]==4&&
				myArray[2][3]==5&&
				myArray[3][1]==6&&
				myArray[3][2]==7&&
				myArray[3][3]==8
			   ){funcClear();}ckClick=true;
		}
		private function funcClear(){				
			for(var j:int=0; j < 8; j++){
				var rndX:Number=rndArray[Math.floor(Math.random()*2)];
				var rndY:Number=rndArray[Math.floor(Math.random()*2)];
				Tweener.addTween(_BlockList[j], {x:rndX,y:rndY,delay:1+j/10,time:1.5,transition : "easeOutQuad"});
			}
			var letterMat = new Letter3DMaterial(0xE3DA37,1);
			letterMat.doubleSided=true;
			var strCo = new Text3D("Congratulations!", new HelveticaBold(), letterMat);
			strCo.z=2000;
			strCo.scaleX=strCo.scaleY=1.5;
			rootNode.addChild(strCo);				
			Tweener.addTween(strCo, {rotationY:360,delay:2,time:5,transition : "easeOutQuad"});
			Tweener.addTween(camera, {z:-800,y:10,x:0,delay:2,time:3,transition : "easeOutQuad"});
		}
		//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
		private function loop( event:Event ):void {singleRender();}	
		//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	}
}

//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import flash.display.Sprite;
import flash.filters.GlowFilter;
import flash.text.*;
class drawBlockFront extends Sprite{
		public var _color:Array=[0xFFCCA7,0xFCC9DC,0xFFCCA7,0xFFDA8C,0xFFB67F,0xFFDA8C,0xFFCCA7,0xFCC9DC];
		public var _color1:Array=[0xFB5E79,0xFE8D8D,0xFB5E79,0xFF9575,0xFF7268,0xFF9575,0xFB5E79,0xFE8D8D];
public function drawBlockFront(nums:Number,str:String){
		var block_sp:Sprite = new Sprite();
		block_sp.name="block_sp";
		block_sp.graphics.beginFill(_color[nums]);
		block_sp.graphics.drawRect(0,0,50,50);
		block_sp.graphics.endFill();
		
		var _pic:drawFlower=new drawFlower(0xffffff);
		block_sp.addChild(_pic);
		_pic.alpha=0.8;
		_pic.scaleX=_pic.scaleY=5;
		_pic.x=25;							
		_pic.y=25;
		
		if(nums==8){this.alpha=0;}	else{
			var fmt:TextFormat = new TextFormat();
			fmt.color = _color1[nums];			
			fmt.size  = 40;
			fmt.font="Impact"
			var _txt = new TextField();
			_txt.name="_txt";
			_txt.defaultTextFormat = fmt;
			_txt.text=str;
			_txt.x=15;
			_txt.y=1;
			_txt.selectable = false;
			block_sp.addChild(_txt);
		}
		filters = [ new GlowFilter( _color1[nums], 1, 20, 20, 1,2,true ) ] ;	
		addChild(block_sp);
		mouseChildren = false;		
}}

class drawBlockSide extends Sprite{
		public var _color:Array=[0xFFCCA7,0xFCC9DC,0xFFCCA7,0xFFDA8C,0xFF917A,0xFFDA8C,0xFFCCA7,0xFCC9DC];//FF9B9B
		public var _color1:Array=[0xFB5E79,0xFE8D8D,0xFB5E79,0xFF9575,0xFF4074,0xFF9575,0xFB5E79,0xFE8D8D];//DD4969
public function drawBlockSide(nums:Number){
		var block_sp:Sprite = new Sprite();
		block_sp.name="block_sp";
		block_sp.graphics.beginFill(_color[nums]);
		block_sp.graphics.drawRect(0,0,50,50);
		block_sp.graphics.endFill();
		
		var _pic:drawFlower=new drawFlower(0xffffff);
		block_sp.addChild(_pic);
		_pic.scaleX=_pic.scaleY=2;
		_pic.x=25;							
		_pic.y=25;
		
		filters = [ new GlowFilter( _color1[nums], 1, 20, 20, 1,2,true ) ] ;	
		addChild(block_sp);
		mouseChildren = false;		
}}

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);
			}		
	}
}
class back_ground extends Sprite{
public function back_ground(){
	var bg:Sprite=new Sprite();
	bg.graphics.beginFill(0xFFFFFF,1);
	bg.graphics.drawRect(0,0,465,465);
	bg.graphics.endFill();
	addChild(bg);
	for(var j:uint=0; j < 100; j++) {
		var panel:drawFlower=new drawFlower(0xFFFFFF);		
		panel.x=Math.floor (Math.random() * 465);
		panel.y=Math.floor (Math.random() * 465);
		panel.scaleX=panel.scaleY=Math.floor (Math.random() * 3)+2;
		panel.rotation=Math.floor (Math.random() * 465);
		panel.filters = [ new GlowFilter(0xFFB8A2, 1, 20, 20, 1,2,false ) ] ;	
		bg.addChild(panel);
	}
}
}