# Triangles

**URL:** <https://forum.kirupa.com/t/triangles/200765>\
**Category:** open source\
**Created:** [September 14, 2006, 10:46pm UTC](https://forum.kirupa.com/t/triangles/200765 "2006-09-14T22:46:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mofongo9](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@mofongo9](https://forum.kirupa.com/u/mofongo9)\
**Post date:** [September 14, 2006, 10:46pm UTC](https://forum.kirupa.com/t/triangles/200765/1 "2006-09-14T22:46:32Z")

</div>

Meh not my best. I just thought of the idea in science class one day (for no reason) and i wrote the code in class and finished it up when i got home.

i know theres probably a lot of unnecessary code but im rusty in scripting cause ive been on a break from it for a while.  
i hope you enjoy for some reason.

```auto
x = random(5)+3;
y = random(5)+3
x2 = random(5)+3;
y2 = random(5)+3;
line1x = 0;
line1y = 400;
line2x = 550;
line2y = 400;
i = 10;
myFill=Math.random()*0xFFFFFF
linethickness = 13;
emptylinespeed = 4;
linestat = "unset";
createEmptyMovieClip("shape", 0);
createEmptyMovieClip("line1", 1);
createEmptyMovieClip("line2", 2);
cut = function (target:String) {
    if (target == "line1") {
        createEmptyMovieClip("emptyline", 3);
        emptyline.lineStyle(linethickness, 0xFF0000, 100);
        emptyline.moveTo(line1x, line1y);
        emptyline.lineTo(linex, liney);
    } else {
        createEmptyMovieClip("emptyline", 3);
        emptyline.lineStyle(linethickness, 0xFF0000, 100);
        emptyline.moveTo(line2x, line2y);
        emptyline.lineTo(linex, liney);
    }
};
onEnterFrame = function () {
    if (linestat == "set") {
        emptyline._y -= emptylinespeed;
        emptylinespeed -= .5;
        emptyline._alpha -= 2;
        line1.clear();
        line2.clear();
        with (shape) {
            clear();
            lineStyle(_root.linethickness, 0x000000, 100);
            beginFill(myFill, 100);
            moveTo(0, 400);
            lineTo(550, 400);
            lineTo(linex, liney);
            lineTo(0, 400);
        }
    } else {
        with (line1) {
            clear();
            lineStyle(_root.linethickness, 0x000000, 100);
            moveTo(0, 400);
            lineTo(line1x, line1y);
        }
        with (line2) {
            clear();
            lineStyle(_root.linethickness, 0x000000, 100);
            moveTo(550, 400);
            lineTo(line2x, line2y);
        }
        line1x += x;
        line1y -= y;
        line2x -= x2;
        line2y -= y2;
        if (line1.hitTest(line2x, line2y, true)) {
            linex = line2x;
            liney = line2y;
            linestat = "set";
            _root.cut("line1");
        } else if (line2.hitTest(line1x, line1y, true)) {
            linex = line1x;
            liney = line1y;
            linestat = "set";
            _root.cut("line2");
        } else if (line1x == line2x && line1y == line2y) {
            linex = line1x;
            liney = line1y;
            linestat = "set";
        }
    }
};

```

[http://img220.imageshack.us/my.php?image=triangledrawermt1.swf](http://img220.imageshack.us/my.php?image=triangledrawermt1.swf)
