flash on 2012-6-12
//preloader
/**
* 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/syp2
*/
package {
import flash.display.Sprite;
import flash.events.*;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
// Tweener
import caurina.transitions.Tweener;
[SWF(width = "465", height = "465", backgroundColor = 0xffffff, frameRate = "60")]
public class Main extends Sprite{
private var myList:Array=new Array();
private var infoList:Array=new Array( {x:0,y:0,cl:0x66CCCC},{x:22,y:0,cl:0xFF9999},{x:44,y:0,cl:0x99CC99},{x:44,y:22,cl:0x9999CC},{x:22,y:44,cl:0xFFCCCC},{x:0,y:22,cl:0xFFCC99});
private var sP:uint=200;
private var nowMovStyle:uint=0;
private var nowSandwich:Object={x:44+sP,y:44+sP};
private var nextMove:Array=new Array();
private var text1= new TextField();
public function Main(){
this.graphics.lineStyle(1,0xFB9394);
this.graphics.drawRect(2,2,460,460);
this.graphics.endFill();
//最初に
for (var q:int=0; q < 6; q++) {
var mc:colorChip=new colorChip(infoList[q]);
mc.name="cc"+q;
mc.x=sP+infoList[q].x
mc.y=sP+infoList[q].y
addChild(mc);
myList.push(mc);
}
var cc:centerChip=new centerChip();
cc.x=22+sP;
cc.y=22+sP;
addChild(cc);
var fmt:TextFormat = new TextFormat();
fmt.size = 11;
fmt.color = 0x222222;
fmt.font="_typewriter";
//text_DispTime
text1.defaultTextFormat = fmt;
text1.text="Now Loading..."
text1.x=sP-18;
text1.y=sP+70;
addChild(text1);
f_search1();
}
private function f_search1(){
textXX();
var nextArr:Array=new Array();
var nx:uint=nowSandwich.x;
var ny:uint=nowSandwich.y;
switch(nowMovStyle){
case 0://←↓
nextArr=f_search2({x:nx-22,y:ny},{x:nx,y:ny-22});
Tweener.addTween(nextArr[0], {x:nextArr[0].x-22, time:0.2, transition:"linear"});
Tweener.addTween(nextArr[1], {y:nextArr[1].y+22, time:0.2, transition:"linear", onComplete:function(){
nowSandwich.y=ny-22;
nowMovStyle=1;
f_search1();
}});
break;
case 1://←↓
nextArr=f_search2({x:nx,y:ny+22},{x:nx,y:ny-22});
Tweener.addTween(nextArr[0], {x:nextArr[0].x-22, time:0.2, transition:"linear"});
Tweener.addTween(nextArr[1], {y:nextArr[1].y+22, time:0.2, transition:"linear", onComplete:function(){
nowSandwich.y=ny-22;
nowMovStyle=2;
f_search1();
}});
break;
case 2://↓→
nextArr=f_search2({x:nx,y:ny+22},{x:nx-22,y:ny});
Tweener.addTween(nextArr[0], {y:nextArr[0].y+22, time:0.2, transition:"linear"});
Tweener.addTween(nextArr[1], {x:nextArr[1].x+22, time:0.2, transition:"linear", onComplete:function(){
nowSandwich.x=nx-22;
nowMovStyle=3;
f_search1();
}});
break;
case 3://↓→
nextArr=f_search2({x:nx+22,y:ny},{x:nx-22,y:ny});
Tweener.addTween(nextArr[0], {y:nextArr[0].y+22, time:0.2, transition:"linear"});
Tweener.addTween(nextArr[1], {x:nextArr[1].x+22, time:0.2, transition:"linear", onComplete:function(){
nowSandwich.x=nx-22;
nowMovStyle=4;
f_search1();
}});
break;
case 4://↓→
nextArr=f_search2({x:nx+22,y:ny},{x:nx,y:ny+22});
Tweener.addTween(nextArr[0], {x:nextArr[0].x+22, time:0.2, transition:"linear"});
Tweener.addTween(nextArr[1], {y:nextArr[1].y-22, time:0.2, transition:"linear", onComplete:function(){
nowSandwich.y=ny+22;
nowMovStyle=5;
f_search1();
}});
break;
case 5://↑→
nextArr=f_search2({x:nx,y:ny-22},{x:nx,y:ny+22});
Tweener.addTween(nextArr[0], {x:nextArr[0].x+22, time:0.2, transition:"linear"});
Tweener.addTween(nextArr[1], {y:nextArr[1].y-22, time:0.2, transition:"linear", onComplete:function(){
nowSandwich.y=ny+22;
nowMovStyle=6;
f_search1();
}});
break;
case 6://↑←
nextArr=f_search2({x:nx,y:ny-22},{x:nx+22,y:ny});
Tweener.addTween(nextArr[0], {y:nextArr[0].y-22, time:0.2, transition:"linear"});
Tweener.addTween(nextArr[1], {x:nextArr[1].x-22, time:0.2, transition:"linear", onComplete:function(){
nowSandwich.x=nx+22;
nowMovStyle=7;
f_search1();
}});
break;
case 7://↑←
nextArr=f_search2({x:nx-22,y:ny},{x:nx+22,y:ny});
Tweener.addTween(nextArr[0], {y:nextArr[0].y-22, time:0.2, transition:"linear"});
Tweener.addTween(nextArr[1], {x:nextArr[1].x-22, time:0.2, transition:"linear", onComplete:function(){
nowSandwich.x=nx+22;
nowMovStyle=0;
f_search1();
}});
break;
default:
break;
}
}
private function f_search2(arg1,arg2):Array{
var arr:Array=new Array();
//一個目探知
for (var q:int=0; q < 6; q++) {
var mc=myList[q];
if(mc.x==arg1.x&&mc.y==arg1.y){
arr.push(mc);
continue;
}
}
//二個目探知
for (q=0; q < 6; q++) {
mc=myList[q];
if(mc.x==arg2.x&&mc.y==arg2.y){
arr.push(mc);
continue;
}
}
return arr;
}
private function textXX():void{
if(text1.text=="Now Loading"){text1.text="Now Loading.";}
else if(text1.text=="Now Loading."){text1.text="Now Loading..";}
else if(text1.text=="Now Loading.."){text1.text="Now Loading...";}
else if(text1.text=="Now Loading..."){text1.text="";}
else if(text1.text==""){text1.text="Now Loading";}
}
}//
}
import flash.display.*;
import flash.geom.Matrix;
import flash.events.*;
//colorChip
class colorChip extends Sprite{
public function colorChip(arg){
for(var j:int=0; j < 24; j++){
this.graphics.beginFill(arg.cl);
this.graphics.drawRoundRect(0,0,20,20,5);
this.graphics.endFill();
var sh:Sprite=new Sprite();
var gbm:Matrix = new Matrix();
var rot:Number = 2 * Math.PI * (90 / 360);
gbm.createGradientBox(20,20,rot,0,-7);
sh.graphics.beginGradientFill(GradientType.LINEAR,[0xFFFFFF,0xFFFFFF], [0.08,0], [0,225],gbm);
sh.graphics.drawRoundRect(1.45,1.45,17,17,8);
sh.graphics.endFill();
addChild(sh);
}
}
}
//centerChip
class centerChip extends Sprite{
public function centerChip(){
for(var j:int=0; j < 24; j++){
this.graphics.lineStyle(1.5,0xCCCCCC);
this.graphics.beginFill(0xEDEDED);
this.graphics.drawRoundRect(0,0,20,20,5);
this.graphics.endFill();
}
}
}