forked from: Tiling smile
とりあえずtweensyのテスト
// forked from chimanaco's Tiling smile
// forked from chimanaco's smile
// forked from chabudai's doraを描いてみた
//とりあえずtweensyのテスト
package {
import flash.display.Sprite;
import flash.geom.ColorTransform;
import caurina.transitions.Tweener;
import com.flashdynamix.motion.Tweensy;
import fl.motion.easing.*;
[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="30")]
public class TilingSmile extends Sprite {
private var smile:Smile;
private var _centerX:Number = stage.stageWidth / 2;
private var _centerY:Number = stage.stageHeight / 2;
private var _x:Number = 50;
private var _y:Number = 50;
private var _r:Number = 25;
private var _num:int = 10;
private var _alpha:int = 10;
private var _dc:Number = 0;
private var _sc:Number = .1;
public function TilingSmile() {
for (var i:int = 0; i < _num; i++) {
var color:ColorTransform = new ColorTransform();
color.redMultiplier = _dc + _sc * i;
for (var j:int = 0; j < _num; j++) {
color.greenMultiplier = _dc + _sc * j;
smile = new Smile( -_r, -_r, _r);
smile.scaleX = smile.scaleY = 0.1;
smile.transform.colorTransform = color;
addChild(smile);
Tweensy.fromTo(smile,{x:Math.random()*400,y:Math.random()*400}, {x:j*50, y:i*50, scaleX:1,scaleY:1},2,Quartic.easeInOut,0);
}
}
}
}
}
import flash.display.Sprite;
class Smile extends Sprite {
private var sp:Sprite;
private var centerX:Number;
private var centerY:Number;
private var defSize:Number = 200;
private var color:int = 0x000000;
public function Smile(centerX:Number, centerY:Number, r:Number = 200, alpha:Number = 1 , fcolor:int = 0xFFFF00) {
sp = new Sprite();
sp.x = centerX;
sp.y = centerY;
var face:Sprite = new Sprite();
face.graphics.beginFill(fcolor);
face.graphics.drawCircle( 0, 0, defSize);
face.graphics.endFill();
var lefteye:Sprite = new Sprite();
lefteye.x = -85;
lefteye.y = -85;
drawOval(lefteye, 35, 70);
var righteye:Sprite = new Sprite();
righteye.x = 55;
righteye.y = -85;
drawOval(righteye, 35, 70);
var mouse:Sprite = new Sprite();
mouse.graphics.lineStyle(12, color);
mouse.graphics.moveTo( -131, 45);
mouse.graphics.curveTo( -84, 130, 0, 130);
mouse.graphics.curveTo(84, 130, 131, 45);
var leftcheek:Sprite = new Sprite();
leftcheek.x = -120;
leftcheek.y = 27;
drawOval(leftcheek, 15, 40);
leftcheek.rotation = 50;
var rightcheek:Sprite = new Sprite();
rightcheek.x = 113;
rightcheek.y = 37;
drawOval(rightcheek, 15, 40);
rightcheek.rotation = -50;
sp.addChild(face);
sp.addChild(lefteye);
sp.addChild(righteye);
sp.addChild(mouse);
sp.addChild(leftcheek);
sp.addChild(rightcheek);
addChild(sp);
//custom
sp.scaleX = sp.scaleY = r / defSize ;
sp.alpha = alpha;
}
private function drawOval(s:Sprite, w:Number, h:Number):void {
s.graphics.beginFill(color, 100);
s.graphics.moveTo(0, h/2);
s.graphics.curveTo(0.5, 0.5, w/2, 0);
s.graphics.curveTo(w-0.5, 0.5, w, h/2);
s.graphics.curveTo(w-0.5, h-0.5, w/2, h);
s.graphics.curveTo(0.5, h-0.5, 0, h/2);
s.graphics.endFill();
}
}