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

Heart Generator

I am making something for my girlfriend for valentines and needed a heart shape, figure why not toss it out there for anyone to use.
Get Adobe Flash player
by netgrind 14 Feb 2013
/**
 * Copyright netgrind ( http://wonderfl.net/user/netgrind )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6Acc
 */

package {
    import flash.display.Graphics;
    import flash.display.Sprite;    
    /**
     * @author netgrind
     * HAPPY VALENTINES :D
     * You can use this code to draw a heart shape (reg point in center)
     */
    public class Heart extends Sprite {       
        
        public function Heart():void {
            var h:Sprite = drawHeart(stage.stageHeight);
            h.x = stage.stageHeight*.5;
            h.y = stage.stageHeight*.5;
            addChild(h);
        }
        
        public static function drawHeart(size:int = 100, color:uint = 0xFF0000, alpha:Number = 1):Sprite {
            var s: Sprite = new Sprite();
            var g:Graphics = s.graphics;
            g.beginFill(color, alpha);;
            g.moveTo(0, size * -.25);
            g.cubicCurveTo(size*-.1, size*-.5, size*-.5,size*-.4,size*-.5, size*-.1);
            g.cubicCurveTo(size*-.5, size*.1, size*-.1,size*.4,0, size*.5);
            g.cubicCurveTo(size*.1,size*.4, size*.5, size*.1,size*.5, size*-.1);
            g.cubicCurveTo(size*.5,size*-.4, size*.1, size*-.5,0, size*-.25);
            g.endFill();
            return s;
        }        
    }    
}