2009といえば牛年
// forked from ogty's 2009
// forked from nitoyon's Hello World!!!
package{
import flash.display.*;
import flash.text.*;
import caurina.transitions.Tweener;
[SWF(width="465", height="465", backgroundColor="0x333333", frameRate="24")]
public class Foo extends Sprite{
private var bd:BitmapData;
public function Foo():void{
var tf:TextField = new TextField();
tf.textColor = 0x000000;
tf.text = "20\n09";
tf.autoSize = "left";
var format:TextFormat = new TextFormat();
format.size = 13;
format.font = "_ゴシック";
format.leading = -3;
tf.setTextFormat( format );
bd = new BitmapData(tf.width, tf.height, false, 0xffffff);
bd.draw(tf);
for(var i:int = 0; i < bd.width; i++){
for(var j:int = 0; j < bd.height; j++){
var color:Number = bd.getPixel(i, j);
if( !color ){
var myCow:Cow = new Cow();
myCow.x = i * 20 + 78;
myCow.y = j * 20 - 20;
myCow.alpha = 1;
myCow.scaleX = myCow.scaleY = 0;
addChild(myCow);
Tweener.addTween(
myCow,
{
alpha: 1,
scaleX: 0.5,
scaleY: 0.5,
delay: (i + j) * .1 * Math.random(),
time: 1
}
);
}
}
}
}
}
}
import flash.display.Sprite;
import flash.events.*;
import caurina.transitions.Tweener;
class Cow extends Sprite{
private var rollVar:uint = 0;
public function Cow():void{
var body:Sprite = new Sprite();
//左角
body.graphics.beginFill(0xFEF19A);
body.graphics.moveTo(-15, -20);
body.graphics.lineTo(-13, -6);
body.graphics.lineTo(-8, -10);
body.graphics.endFill();
//右角
body.graphics.beginFill(0xFEF19A);
body.graphics.moveTo(15, 0);
body.graphics.lineTo(13, -6);
body.graphics.lineTo(8, -10);
body.graphics.endFill();
//左耳
body.graphics.beginFill(0x000000);
body.graphics.moveTo(-20, -10);
body.graphics.lineTo(-10, -11);
body.graphics.lineTo( -13, -5);
body.graphics.endFill();
//右耳
body.graphics.beginFill(0x000000);
body.graphics.moveTo(20, -10);
body.graphics.lineTo(10, -11);
body.graphics.lineTo( 13, -5);
body.graphics.endFill();
//顔面
body.graphics.beginFill(0xFFFFFF);
body.graphics.drawEllipse(-16, -15, 33, 34);
body.graphics.beginFill(0x000000);
body.graphics.drawCircle(7, -6, 8);
body.graphics.drawEllipse(-8, -10, 3, 8);
body.graphics.endFill();
body.graphics.beginFill(0xFFFFFF);
body.graphics.drawEllipse(5, -10, 3, 8);
body.graphics.endFill();
//口鼻
body.graphics.beginFill(0xFEF19A);
body.graphics.drawEllipse(-17, 3, 34, 17);
body.graphics.endFill();
body.graphics.beginFill(0x000000);
body.graphics.drawCircle(-6, 12, 4);
body.graphics.drawCircle(5, 12, 4);
body.graphics.endFill();
addChild(body);
mouseEnabled = true;
addEventListener( MouseEvent.MOUSE_OVER, onMouse );
}
private function onMouse( event:MouseEvent ):void{
rollVar = 30;
scaleX = scaleY = 1.5;
addEventListener( Event.ENTER_FRAME, onEnterframe );
}
private function onEnterframe( event:Event ):void{
var cc:Sprite = event.target as Sprite;
cc.rotation += rollVar;
if( rollVar > 0 ){
rollVar--;
}else{
removeEventListener( Event.ENTER_FRAME, onEnterframe );
}
if( scaleX > 0.5){
scaleX -= 0.05;
scaleY -= 0.05;
}else{
scaleX = scaleY = 0.5;
}
}
}