PDA

View Full Version : Two lines drawn


fiona
05-13-2005, 07:56 PM
I have one line drawn by this AS. I want another line drawn that cross the first line. The result shall be something like a X . Can anybody help me with this. I have tried but I donīt get seperated lines.


lineStyle(0);
var pos = 10;
var posx = 10;
moveTo(posx, pos);

onEnterFrame = function() {
if (pos < 200) {
pos = pos + 5;

};
if (posx < 200) {
posx = posx + 5;

};
lineTo(posx, pos);


};

jimmyhay
05-13-2005, 09:39 PM
After much playing around with various things, I managed to do it. Not sure if this is the best to go about this, but none the less here you are. It works though.


_root.createEmptyMovieClip("line1_mc", 1);
_root.createEmptyMovieClip("line2_mc", 2);
line1_mc.lineStyle(1, 0xFFFFFF, 100);
line2_mc.lineStyle(1, 0xFFFFFF, 100);
var x1 = 30;
var y1 = 30;
var x2 = 270;
var y2 = 30;
line1_mc.moveTo(x1, y1);
line2_mc.moveTo(x2, y2);

function line1() {
x1 += 2;
y1 += 2;
line1_mc.lineTo(x1, y1);
}

function line2() {
x2 -= 2;
y2 += 2;
line2_mc.lineTo(x2, y2);
}

_root.onEnterFrame = function () {
if (x1 < 270) {
line1();
}
if (x1 == 270) {
if (x2 > 30) {
line2();
}
}
}

fiona
05-13-2005, 09:49 PM
Thanks a lot, but I canīt see any lines when I try it!

cxn926
05-13-2005, 09:51 PM
i think you have to have instance names like line1_mc and line2_mc

jimmyhay
05-13-2005, 09:58 PM
Okay firstly, did u copy the code exactly?

Secondly, the lines drawn are white, so you might wanna make the background colour of your movie a dark colour so u can actually see the lines. Lol, not sure why I made them white, just thought it would look nice on a black background.

Does it work now?

fiona
05-13-2005, 10:06 PM
I changed the lines drawn to black. Now it works perfectly. I really appreciate your work. THANK YOU!!