In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

ハート出まくり

AS3でハートを描画する方法
あくまでも線なのでマスクとかはできませんけど
(・x・)ノ ピシッ
Get Adobe Flash player
by pippo 18 Mar 2009
// forked from zahir's Hart
// write as3 code here..

//AS3でハートを描画する方法
//あくまでも線なのでマスクとかはできませんけど


/*
(・x・)ノ ピシッ
*/

package {
    import flash.display.*;
    import flash.geom.Point;
    import flash.utils.setInterval;
    import caurina.transitions.Tweener;
    
    public class tweenTest extends Sprite {
        private var prevPos:Point;
        
        public function tweenTest():void {
            prevPos = new Point();
            setInterval(update, 100);
        }
        
        private function update():void {
            var r:Number = Math.pow(Math.random(), 2) * 50;
            var theta:Number = Math.random() * 2 * Math.PI;
            
            //ハートを描画
            var myHeart:Sprite = new Sprite();
            myHeart.graphics.lineStyle(100, Math.random() * 0xFFFFFF, 1.0, false,
                LineScaleMode.NORMAL, CapsStyle.ROUND, JointStyle.MITER);
            myHeart.graphics.moveTo(50,50);
            myHeart.graphics.lineTo(100,100);
            myHeart.graphics.lineTo(150,50);

            myHeart.x = mouseX + r * Math.cos(theta);
            myHeart.y = mouseY + r * Math.sin(theta);
            myHeart.scaleX = myHeart.scaleY = 0;
            addChild(myHeart);
            
            //マウスの移動量
            var curPos:Point = new Point(mouseX, mouseY);
            var d:Number = Point.distance(curPos, prevPos);
            prevPos = curPos;
            
            //Tweenerの設定
            Tweener.addTween(myHeart, {
                scaleX: d / 15 + 2,
                scaleY: d / 15 + 2,
                alpha:0,
                time:3,
                onComplete: function():void {
                    removeChild(myHeart);
                }
            });
 
        }
    }
}