tweenerでお絵かき
Tweenerの練習
/**
* Copyright teageek ( http://wonderfl.net/user/teageek )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/nRAh
*/
//Tweenerの練習
package {
import flash.display.*;
import flash.events.*;
import caurina.transitions.Tweener;
import flash.display.BlendMode;
import flash.text.*;
import flash.geom.Point;
[SWF(width = "465", height = "465", backgroundColor = 0x0, frameRate = "60")]
public class Tw extends MovieClip{
private var isPress:Boolean= false;
private var tf:TextField= new TextField();
private var tf2:TextField = new TextField();
private var tf3:TextField;
private var c:int =0;
private var ball:Sprite= new Sprite();
private var tn:Array = [ "linear", "easeinquad", "easeoutquad", "easeinoutquad", "easeoutinquad", "easeincubic", "easeoutcubic", "easeinoutcubic", "easeoutincubic", "easeinquart", "easeoutquart", "easeinoutquart", "easeoutinquart", "easeinquint", "easeoutquint", "easeinoutquint", "easeoutinquint", "easeinsine", "easeoutsine", "easeinoutsine", "easeoutinsine", "easeincirc", "easeoutcirc", "easeinoutcirc", "easeoutincirc", "easeinexpo", "easeoutexpo", "easeinoutexpo", "easeoutinexpo", "easeinelastic", "easeoutelastic", "easeinoutelastic", "easeoutinelastic", "easeinback", "easeoutback", "easeinoutback", "easeoutinback", "easeinbounce", "easeoutbounce", "easeinoutbounce", "easeoutinbounce" ];
private var xArr:Array=[123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,125,125,126,126,127,127,130,132,133,133,133,135,140,141,146,146,147,150,154,154,155,155,158,159,161,165,165,165,167,167,167,168,168,169,169,170,170,170,170,171,171,171,171,171,172,172,172,172,172,173,173,173,173,175,175,175,175,175,175,175,175,175,175,175,175,175,107,107,107,107,107,108,108,110,114,117,123,131,142,146,147,147,147,150,150,154,154,158,158,162,167,169,172,174,174,175,175,177,178,178,179,179,179,180,180,180,181,181,181,181,181,182,182,182,183,183,183,183,184,184,184,184,184,184,184,185,185,185,185,185,186,186,186,188,188,188,189,189,189,189,189,189,189,159,159,159,159,159,159,159,157,157,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,154,154,154,154,152,152,152,149,149,148,147,147,147,147,145,144,143,143,143,142,142,142,140,140,139,139,139,138,134,133,133,132,132,132,132,132,132,132,130,130,130,130,130,130,130,130,130,130,130,194,194,194,194,194,194,194,194,196,198,203,204,204,205,210,213,223,223,223,227,227,227,228,231,233,233,236,236,236,236,237,237,238,238,238,238,238,238,238,238,238,238,238,238,238,238,238,238,238,238,236,236,236,233,233,233,233,233,233,231,231,231,231,231,231,229,229,229,229,227,227,223,223,223,221,221,217,217,217,216,212,212,205,205,201,201,198,197,193,190,190,187,187,186,186,186,186,186,186,186,183,183,183,183,183,183,183,183,183,183,183,183,183,183,183,219,219,219,220,220,220,221,221,221,222,225,225,227,227,227,227,227,227,228,228,228,229,229,229,229,234,234,235,235,235,236,236,236,237,237,238,238,238,238,239,239,239,240,240,240,240,240,240,240,240,240,240,240,240,262,262,262,262,262,262,262,262,262,262,262,262,262,262,262,262,263,263,263,263,263,263,263,263,263,264,264,264,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,265,263,263,263,263,263,263,263,263,267,268,268,269,269,269,270,270,272,272,273,273,273,274,274,274,275,277,277,277,278,278,278,279,279,279,280,280,280,280,281,281,281,282,282,282,283,283,283,284,284,285,285,285,286,286,286,287,287,287,287,288,288,288,289,289,289,289,290,290,290,291,291,294,294,294,294,294,296,296,296,296,296,296,296,296,296,296,296,296,319,319,319,319,319,319,319,319,319,319,319,319,319];
private var yArr:Array=[123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,161,161,161,161,161,162,162,162,162,167,169,169,171,171,171,172,172,173,173,173,174,176,179,179,180,180,180,181,181,181,181,182,182,182,182,184,184,184,185,185,187,187,187,187,190,190,190,190,190,190,191,191,191,191,191,191,192,193,193,193,193,193,193,194,194,194,194,194,194,194,194,194,194,194,194,194,194,194,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,187,187,187,188,188,189,189,193,193,193,197,197,197,197,198,198,198,199,199,199,200,201,201,203,204,204,208,209,209,209,209,213,213,213,214,215,216,220,221,222,223,223,223,225,225,226,226,226,226,226,227,227,227,227,227,227,227,227,227,227,227,227,227,227,227,227,227,227,227,227,206,206,206,206,206,206,206,206,206,211,211,211,212,212,212,212,212,212,213,213,213,213,214,214,214,216,216,216,216,217,217,218,218,218,219,219,219,219,219,219,220,220,220,220,220,221,221,221,221,221,221,221,221,221,226,226,226,226,226,228,230,230,236,241,243,248,248,252,258,259,259,261,261,263,263,263,265,265,266,270,270,271,271,272,272,272,274,274,274,277,278,278,279,279,279,279,280,280,284,284,288,288,288,289,289,289,289,289,289,290,290,290,290,290,290,290,290,257,257,257,257,257,257,257,257,255,255,256,256,256,256,256,257,257,257,257,257,257,257,258,258,258,258,258,258,258,259,259,259,259,259,259,259,259,259,259,260,260,260,260,260,260,260,260,260,261,261,261,261,261,261,261,261,261,261,261,261,261,261,261,261,261,261,261,262,262,262,262,262,262,262,262,262,262,262,262,262,262,262,262,262,262,262,262,262,265,265,265,265,265,265,265,265,265,265,265,265,265];
private var rec:Boolean =false;
public function Tw(){
graphics.beginFill(0);
graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
tf.selectable=false;
tf.width=50;
tf.height=20;
tf.y=2;
tf.background=true;
tf.backgroundColor=0xFF;
tf.border=true;
tf.borderColor=0xFFFFFF;
tf.textColor=0xffffff;
tf.text="(rec/play)";
addChild(tf);
tf2.selectable=false;
tf2.width=60;tf2.height=20;
tf2.y=2;tf2.x=400;
tf2.background=true;
tf2.backgroundColor=0xFF;
tf2.border=true;
tf2.borderColor=0xFFFFFF;
tf2.textColor=0xffffff;
tf2.text="(mode)";
addChild(tf2);
stage.addEventListener(MouseEvent.MOUSE_DOWN,function():void{isPress=true;});
stage.addEventListener(MouseEvent.MOUSE_UP,function():void{isPress= false;});
stage.addEventListener(Event.ENTER_FRAME,function():void{
if(xArr.length>0)if(!rec)make(int(xArr.shift()),int(yArr.shift()));
if(isPress)make();});
tf.addEventListener(MouseEvent.CLICK,function():void{
if(rec)rec=false,/*trace("x",xArr),trace("y",yArr),*/tf.text="play",tf.backgroundColor=0x00ff;
else rec=true,trace("rec"),tf.text="rec",tf.backgroundColor=0xff00ff;});
tf2.addEventListener(MouseEvent.MOUSE_UP,function():void{c++});
}
private function make(_x:Number=0,_y:Number=0):void{
if(_x==0){ _x= stage.mouseX; _y=stage.mouseY;}
if(isPress)if(rec)xArr.push(_x),yArr.push(_y);
if(c%2==0)
{
tf2.text="BallMode";
ball = new Sprite();
ball.graphics.beginFill(0xffffff*Math.random());
ball.graphics.drawCircle(0,0,2);
ball.graphics.endFill();
ball.x = Math.random()*465;
ball.y =Math.random()*465;
addChild(ball);
Tweener.addTween(ball,{x:_x,y:_y,time:0.5,transition:tn[int(Math.random()*tn.length)]});
Tweener.addTween(ball,{delay:5,onComplete:function():void{removeChild(this);}});
}
else
{
tf2.text="textMode";
tf3 = new TextField();
tf3.x = Math.random()*465;
tf3.y =Math.random()*465;
tf3.selectable=false;
tf3.text=""+_x+":"+_y;
tf3.textColor=0xffffff;
addChild(tf3);
Tweener.addTween(tf3,{x:_x,y:_y,time:0.5,transition:tn[int(Math.random()*tn.length)]});
Tweener.addTween(tf3,{delay:5,onComplete:function():void{removeChild(this);}});
}
}
}
}