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

forked from: forked from: forked from: flash on 2009-8-19

but now it's gone too far from it...
Get Adobe Flash player
by ohisama 03 Feb 2013
    Embed
/**
 * Copyright ohisama ( http://wonderfl.net/user/ohisama )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/5PTa
 */

// forked from tenasaku's forked from: forked from: flash on 2009-8-19
// forked from hacker_kuukuu's forked from: flash on 2009-8-19
// but now it's gone too far from it...
package 
{
    import flash.display.Sprite;
    public class FlashTest extends Sprite 
    {
        public function FlashTest() : void 
        {
            var i : uint;
            var kame : LineDrawer = new LineDrawer();
            kame.Walk(100);
            kame.Turn(90)
            kame.Walk(100);
            kame.Turn(90);
            kame.Walk(100);
            kame.Turn(90);
            kame.Walk(100);
            kame.Teleport(100);
            kame.Walk(100);
            kame.Turn(120)
            kame.Walk(100);
            kame.Turn(120);
            kame.Walk(100);
            kame.Teleport(100);
            kame.Walk(100);
            kame.Turn(144);
            kame.Walk(100);
            kame.Turn(144);
            kame.Walk(100);
            kame.Turn(144);
            kame.Walk(100);
            kame.Turn(144);
            kame.Walk(100);
            kame.West();
            kame.Teleport(100);
            for ( i = 0; i < 20; ++i )
            {
                kame.Walk(130);
                kame.Turn(126);
            }
            addChild(kame);
        }
    }
}
import flash.display.Sprite;
class LineDrawer extends Sprite
{
    private var x0 : int = 240;
    private var y0 : int = 240;
    private var theta : Number = 90 * Math.PI / 180;
    public function LineDrawer()
    {
        graphics.lineStyle(5, 0x0000ff);
        graphics.moveTo(x0, y0);
    }
    public function Teleport(length : Number) : void 
    {
        if (length >= 0) 
        {
            x0 = Math.round(x0 + length * Math.cos(theta));
            y0 = Math.round(y0 + length * Math.sin(theta));
            graphics.moveTo(x0, y0);
        }
    }
    public function Walk(length : Number) : void 
    {
        if (length >= 0) 
        {
            x0 = Math.round(x0 + length * Math.cos(theta));
            y0 = Math.round(y0 + length * Math.sin(theta));
            graphics.lineTo(x0, y0);
        }
    }
    public function Turn(alpha : Number) : void 
    {
        theta += alpha * Math.PI / 180;
        while (theta >= Math.PI * 2) 
        {
            theta -= Math.PI * 2;
        }
        while (theta < 0) 
        {
            theta += Math.PI * 2;
        }
    }
    public function North() : void 
    {
        theta = 270 * Math.PI / 180;
    }
    public function East() : void 
    {
        theta =  0 * Math.PI / 180;
    }
    public function West() : void 
    {
        theta = 180 * Math.PI / 180;
    }
    public function South() : void 
    {
        theta =  90 * Math.PI / 180;
    }
}