/**
* Copyright naokey0221 ( http://wonderfl.net/user/naokey0221 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/quFB
*/
package
{
import caurina.transitions.Tweener;
import caurina.transitions.properties.ColorShortcuts;
import flash.display.Sprite;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
[SWF(/*width = 500, height = 500,*/ /*frameRate=20,*/ backgroundColor=0xFFFFFF)]
public class pond2 extends Sprite
{
ColorShortcuts.init();
private var frameCount:uint=0;//再生ヘッド(フレーム数カウント用の変数)
private var frameCountLimit:uint=2;//コマ数(最終フレームの位置)
public function pond2()
{
//ステージにクリック・イベントのハンドラを登録する
//stage.addEventListener(MouseEvent.CLICK, onClick);
addEventListener(Event.ENTER_FRAME,onTime);
//池の描画
var mycircle1:DrawCircle = new DrawCircle(200,200,80,0x3399ff);
var mycircles1:DrawCircles=new DrawCircles(200,200,10,10,0x666666,0);
//addChild(mycircle1 );
//addChild(mycircles1 );
}
private function onTime(e:Event): void
{
//半径をランダムでセット
var nR:int =/*Math.ceil(Math.random()*1)+*/5;
//色をランダムで選ぶ
var color:int =0x0033FF; //Math.floor(Math.random()*0xffffff); //
//円のクラスのインスタンス作る
var oneCircle:Sprite = new DrawCircle(0,0,nR,color);
oneCircle.x= Math.round(Math.random()*400)+50; //e.stageX;
oneCircle.y= Math.round(Math.random()*400)+50; //e.stageY;
if(frameCount < frameCountLimit){
addChild(oneCircle);
changeColor(oneCircle,nR,0xFFFFFF);
}else{
frameCount=0;
}
frameCount++;//再生ヘッドを進める
}
private function onClick(e:MouseEvent): void
{
//半径をランダムでセット
var nR:int =/*Math.ceil(Math.random()*1)+*/1;
//色をランダムで選ぶ
var color:int =0xFF3366; //Math.floor(Math.random()*0xffffff); //
//円のクラスのインスタンス作る
var oneCircle:Sprite = new DrawCircle(0,0,nR,color);
oneCircle.x= Math.round(Math.random()*400)+50; //e.stageX;
oneCircle.y= Math.round(Math.random()*400)+50; //e.stageY;
addChild(oneCircle);
changeColor(oneCircle,nR,0xFFFFFF);
}
private function changeColor(oneCircle:Sprite/*Sprite*/,nR:Number,color:int):void
{
Tweener.addTween(oneCircle,{
//x: 50,//e.stageX,
//y: 50,//e.stageY,
scaleX: 1.2*nR,/*//Math.ceil(Math.random()*20)+5,*/
scaleY: 1.2*nR,/*// Math.ceil(Math.random()*20)+5,*/
_color:color,
time:0.7/**Math.ceil(Math.random()*20)*/,
delay:0,
transition: "easeInOutSine",
onComplete: changeColor,
onCompleteParams: [oneCircle]});
}
}
}
import flash.display.Sprite/*Sprite*/;
import caurina.transitions.properties.ColorShortcuts;
class DrawCircle extends Sprite//MovieClip
{
//ColorShortcuts.init();
public function DrawCircle(centerX:int , centerY:int ,r:int,color:int)
{
//alpha=1.0;
//blendMode=BlendMode.HARDLIGHT;
//線の太さを2,色をcolorにセットする
graphics.beginFill(color,1.0);
//graphics.lineStyle(0.7,color);
//centerX,centerYを中心とする半径nRの円を描く
graphics.drawCircle(centerX, centerY, r);
graphics.endFill();
}
}
class DrawCircles extends Sprite
{
public function DrawCircles(centerX:Number,centerY:Number,r:Number,r2:Number,color:int,keisya:int)
{
for(var k:int =0 ;k<360 ;k+=14)
{
graphics.beginFill(color)
graphics.moveTo(200+80*Math.cos(k*Math.PI/180),200+80*Math.sin(k*Math.PI/180));
var x:Number= 200+80*Math.cos(k*Math.PI/180);
var y:Number=200+80*Math.sin(k*Math.PI/180);
for(var d:int =0 ;d<=360 ;d++)
{
var radian:Number =(d+keisya)*Math.PI/180;
graphics.lineTo(
x+r*Math.cos(radian),
y+r2*Math.sin(radian))
}
graphics.endFill()
}
}
}
class DrawCircleW extends Sprite
{
public function DrawCircleW(centerX:Number,centerY:Number,r:Number,r2:Number,color:int,keisya:int)
{
//graphics.beginFill(color)
graphics.lineStyle(2,0xffffff);
graphics.moveTo(centerX+r,centerY);
for(var d:int =0 ;d<360 ;d++)
{
var radian:Number =(d+keisya)*Math.PI/180;
graphics.lineTo(
centerX+r*Math.cos(radian),
centerY+r2*Math.sin(radian))
}
//graphics.endFill()
}
}