forked from: ChickChick
// forked from hacker_cobulht0's ChickChick
package {
import flash.display.Sprite;
import flash.events.*;
[SWF(width = "465", height = "465", backgroundColor = 0xffffff, frameRate = "60")]
public class test extends Sprite{
private var _List:Array=new Array();
private var waveList:Array=new Array();
public function test(){
if (stage) init();else addEventListener(Event.ADDED_TO_STAGE,init );
}
public function init(ev:Event = null){
removeEventListener( Event.ADDED_TO_STAGE, init ) ;
var bg:back_ground=new back_ground();
addChildAt(bg,0);
for(var j:uint=0; j < 50; j++) {
var flower:drawFlower=new drawFlower(Math.random()*0xFFFFFF,0xcccccc);//0x549900
flower.name="wave"+_List.length;
flower.x=j*10+10;
flower.yp=Math.floor (Math.random() * 50)+360;
flower.scaleX=flower.scaleY=Math.floor (Math.random() * 3)+2;
flower.rotation=Math.floor (Math.random() * 465);
flower.addEventListener(Event.ENTER_FRAME,function(e){
var _radian:Number = e.target.angel* Math.PI / 180;
e.target.y = e.target._radius * Math.sin(_radian)+e.target.yp;
e.target.angel+=e.target.speed;
});
waveList.push(flower);
addChild(flower);
}
stage.addEventListener(MouseEvent.MOUSE_DOWN, clicks);
}
private function clicks(ev){
if(mouseY<360){
var mc:drawChick=new drawChick;
mc.name="chick"+_List.length;
mc.x=mouseX;
mc.y=mouseY;
if(mc.dire==1){mc.scaleX=-1;}
_List.push(mc);
mc.addEventListener(Event.ENTER_FRAME,swimming);
addChild(mc);
}
}
private function swimming(ev){
var _mc=ev.target;
if(_mc.y<340){_mc.y++;}
else{
_mc.foot.visible=false;
if(_mc.dire==0){_mc.x--;}else if(_mc.dire==1){_mc.x++;}
var _radian:Number = _mc.angel* Math.PI / 180;
_mc.y = 20 * Math.sin(_radian)+370;
_mc.angel+=2;
if(_mc.x<0||_mc.x>480){
_mc.removeEventListener(Event.ENTER_FRAME,swimming);
removeChild(_mc);
_mc=null;
}
}
}
}
}
//----------------------------------------------------------------------------------------------------
import flash.display.Sprite;
import flash.filters.GlowFilter;
class drawChick extends Sprite{
private var head:Sprite=new Sprite();
private var body:Sprite=new Sprite();
private var scarf:Sprite=new Sprite();
public var foot:Sprite=new Sprite();
public var dire:uint=Math.floor(Math.random()*2);
public var angel:uint=1;
public function drawChick(){
head.graphics.beginFill(0xFFCC33);
head.graphics.drawCircle(0,0,10);//head
head.graphics.endFill();
var head_1:Sprite = new Sprite();
head_1.graphics.beginFill(0x34929A);//eye
head_1.graphics.drawCircle(-1,-1,2);
head_1.graphics.endFill();
head_1.graphics.beginFill(0xF6712E);//mouse
head_1.graphics.drawEllipse(-15,-2,7,4);
head_1.graphics.endFill();
head.addChild(head_1);
addChild(head);
body.graphics.beginFill(0xFFCC33);//body
body.graphics.drawEllipse(2,2,30,20);
body.graphics.endFill();
var body_1:Sprite = new Sprite();
body_1.graphics.beginFill(0xFFCC33);//teil
body_1.graphics.moveTo(20,5);
body_1.graphics.lineTo(35,-1);
body_1.graphics.lineTo(32,13);
body_1.graphics.endFill();
body.addChild(body_1);
addChild(body);
foot.graphics.lineStyle(2,0xF6721E);//foot
foot.graphics.moveTo(18,23);
foot.graphics.lineTo(18,25);
foot.graphics.moveTo(18,25);
foot.graphics.lineTo(15,30);
foot.graphics.moveTo(18,25);
foot.graphics.lineTo(12,28);
foot.graphics.moveTo(18,25);
foot.graphics.lineTo(10,25);
foot.graphics.endFill();
addChild(foot);
scarf.graphics.beginFill(0xEF324E);
scarf.graphics.drawEllipse(-5,8,14,3);
scarf.graphics.endFill();
scarf.rotation=-40;
var scarf_1:Sprite = new Sprite();
scarf_1.graphics.beginFill(0xEF324E);
scarf_1.graphics.drawEllipse(0,0,15,5);
scarf_1.graphics.endFill();
scarf_1.rotation=-60;
scarf_1.x=5;scarf_1.y=8;
var scarf_2:Sprite = new Sprite();
scarf_2.graphics.beginFill(0xEF324E);
scarf_2.graphics.drawEllipse(0,0,15,5);
scarf_2.graphics.endFill();
scarf_2.rotation=-20;
scarf_2.x=5;scarf_2.y=8;
scarf.addChild(scarf_2);
scarf.addChild(scarf_1);
addChild(scarf);
}
}
class drawFlower extends Sprite{
public var speed:Number=Math.floor(Math.random()*2)+1;
public var _radius:Number=Math.floor(Math.random()*20)+10;
public var angel:uint=1;
public var yp:uint=1;
public function drawFlower(col1:Number,col2:Number){
for(var j:int=0; j < 5; j++){
var fl_sp:Sprite = new Sprite();
fl_sp.graphics.beginFill(col1);
fl_sp.graphics.drawEllipse(-1,0.5,2,4);
fl_sp.graphics.endFill();
fl_sp.rotation=j*72+180;
addChild(fl_sp);
}
filters = [ new GlowFilter(col2, 1, 40, 40,2,2,false ) ] ;
}
}
class back_ground extends Sprite{
public function back_ground(){
var bg:Sprite=new Sprite();
bg.graphics.beginFill(0xdddddd,0.5);
bg.graphics.drawRect(0,0,465,465);
bg.graphics.endFill();
for(var j:int=0; j < 2304; j++){
var dot:Sprite=new Sprite();
dot.graphics.beginFill(0xbbbbbb,0.5);
dot.graphics.drawCircle(0,0,4.5);
dot.graphics.endFill();
dot.x=j%48*10;
if(j%2==0){dot.y=Math.floor(j / 48)*20+10;}else{dot.y=Math.floor(j / 48)*20;}
bg.addChild(dot);
}
addChild(bg);
}
}