# Little code problem i can't figure out

**URL:** <https://forum.kirupa.com/t/little-code-problem-i-cant-figure-out/34706>\
**Category:** Uncategorized\
**Created:** [November 5, 2003, 12:46pm UTC](https://forum.kirupa.com/t/little-code-problem-i-cant-figure-out/34706 "2003-11-05T12:46:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![blah\_de\_blah](https://avatars.discourse-cdn.com/v4/letter/b/a8b319/32.png) [@blah\_de\_blah](https://forum.kirupa.com/u/blah_de_blah)\
**Post date:** [November 5, 2003, 12:46pm UTC](https://forum.kirupa.com/t/little-code-problem-i-cant-figure-out/34706/1 "2003-11-05T12:46:34Z")

</div>

Ok so this is the code i made, and everything is working well except for 1 thing ☹ Heres the code (copy and past it to flash to see what it does)…

[AS]  
x1 = 100;  
y1 = 200;  
x2 = 400;  
y2 = 200;  
\_root.onEnterFrame = function() {  
\_root.createEmptyMovieClip(“line”+i, i);  
trace(“controlx=”+controlx);  
trace(“mousex=”+\_root.\_xmouse);  
controlx = \_root.\_xmouse_2-(x2-x1)/2;  
controly = \_root.\_ymouse_2-(y2-y1)/2;  
\_root[“line”+i].lineStyle(2, 0x00FF00, 80);  
\_root[“line”+i].moveTo(x1, y1);  
\_root[“line”+i].curveTo(controlx, controly, x2, y2);  
alphaFade(\_root[“line”+i]);  
i++;  
if (i\>1000) {  
i = 0;  
}  
};  
MovieClip.prototype.alphaFade = function(fadingLine) {  
fadingLine.onEnterFrame = function() {  
fadingLine.\_alpha -= 10;  
if (fadingLine.\_alpha\<=0) {  
fadingLine.clear();  
}  
};  
};  
[/AS]

The problem is, i can’t get the mouse to be the same point as the control point. Without the alpha fading, it works, but without, it doesn’t :-\ Very frustrating. hope someone can help! thanks ! :beam:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 5, 2003, 1:03pm UTC](https://forum.kirupa.com/t/little-code-problem-i-cant-figure-out/34706/2 "2003-11-05T13:03:59Z")

</div>

if you want the mouse to be the same as the control point, then you don’t need that formula to calculate controlx and control y  
[AS]  
x1 = 100;  
y1 = 200;  
x2 = 400;  
y2 = 200;  
\_root.onEnterFrame = function() {  
\_root.createEmptyMovieClip(“line”+i, i);  
trace(“controlx=”+controlx);  
trace(“mousex=”+\_root.\_xmouse);  
controlx = \_root.\_xmouse//\*2-(x2-x1)/2;  
controly = \_root.\_ymouse//\*2-(y2-y1)/2;  
\_root[“line”+i].lineStyle(2, 0x00FF00, 80);  
\_root[“line”+i].moveTo(x1, y1);  
\_root[“line”+i].curveTo(controlx, controly, x2, y2);  
alphaFade(\_root[“line”+i]);  
i++;  
if (i\>1000) {  
i = 0;  
}  
};  
MovieClip.prototype.alphaFade = function(fadingLine) {  
fadingLine.onEnterFrame = function() {  
fadingLine.\_alpha -= 10;  
if (fadingLine.\_alpha\<=0) {  
fadingLine.clear();  
}  
};  
};

```auto

now, if you want the mouse to be at the peak of the curve, you would use this.

```

x1 = 100;  
y1 = 200;  
x2 = 400;  
y2 = 200;  
\_root.onEnterFrame = function() {  
\_root.createEmptyMovieClip(“line”+i, i);  
trace(“controlx=”+controlx);  
trace(“mousex=”+\_root.\_xmouse);  
controlx = \_xmouse_2-(x1+x2)/2;  
controly = \_ymouse_2-(y1+y2)/2;  
\_root[“line”+i].lineStyle(2, 0x00FF00, 80);  
\_root[“line”+i].moveTo(x1, y1);  
\_root[“line”+i].curveTo(controlx, controly, x2, y2);  
alphaFade(\_root[“line”+i]);  
i++;  
if (i\>1000) {  
i = 0;  
}  
};  
MovieClip.prototype.alphaFade = function(fadingLine) {  
fadingLine.onEnterFrame = function() {  
fadingLine.\_alpha -= 10;  
if (fadingLine.\_alpha\<=0) {  
fadingLine.clear();  
}  
};  
};

```auto

if this is what you mean, you almost had it except for you were subtracting instead of adding in these two lines

```

```
    controlx = _xmouse*2-(x1+x2)/2;
    controly = _ymouse*2-(y1+y2)/2;

```

```auto

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 5, 2003, 1:10pm UTC](https://forum.kirupa.com/t/little-code-problem-i-cant-figure-out/34706/3 "2003-11-05T13:10:28Z")

</div>

APdesign yet again comes to the rescue 😛 thank you…i knew it was something small! these little things annoy me Ⓜ
